summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmso-database/etc/config/liquibase.properties13
-rw-r--r--cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-add-uuid.sql93
-rw-r--r--cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-drop-ids.sql18
-rw-r--r--cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-drop-indices.sql28
-rw-r--r--cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-restore-indices.sql92
-rw-r--r--cmso-database/src/main/resources/cmso-liquibase-changeLog.xml9
-rw-r--r--cmso-database/src/main/resources/optimizer-dbchanges/onap-optimizer-v1-schema.sql54
-rw-r--r--cmso-database/src/main/resources/optimizer-liquibase-changeLog.xml48
-rw-r--r--cmso-robot/.project23
-rw-r--r--cmso-robot/docker/Dockerfile19
-rw-r--r--cmso-robot/red.xml117
-rw-r--r--cmso-robot/robot/assets/sql/selectall.sql19
-rw-r--r--cmso-robot/robot/assets/test_properties.py4
-rw-r--r--cmso-robot/robot/locallibrary/cmsoUtils/HTTPUtils.py2
-rw-r--r--cmso-robot/robot/locallibrary/cmsoUtils/JSONUtils.py26
-rw-r--r--cmso-robot/robot/resources/browser_setup.robot2
-rw-r--r--cmso-robot/robot/resources/files.robot1
-rw-r--r--cmso-robot/robot/resources/misc.robot3
-rw-r--r--cmso-robot/robot/resources/scheduler_common.robot4
-rw-r--r--cmso-robot/robot/resources/scheduler_requests/create_schedule.robot4
-rw-r--r--cmso-robot/robot/resources/test_templates/change_management.robot15
-rw-r--r--cmso-robot/robot/resources/test_templates/change_management_ete.robot2
-rw-r--r--cmso-robot/setup.sh30
-rw-r--r--cmso-service/extra/src/main/java/org/onap/optf/utilities/OnapInitialCommit.java297
-rw-r--r--cmso-service/pom.xml24
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java4
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java7
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java13
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java13
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java18
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java10
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/eventq/DispatchedEventList.java16
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java24
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java49
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java39
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java48
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java46
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java28
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/HelloWorld.java58
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java32
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java52
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java163
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleQuery.java23
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java10
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java18
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java20
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java18
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java27
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java10
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java10
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java15
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleEventDAO.java53
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java18
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java78
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java5
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java4
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java13
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java16
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java27
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java74
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java122
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java (renamed from cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSCallbackImpl.java)529
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java6
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java59
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOptimizerCallback.java14
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java342
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java15
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java13
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/ChangeWindow.java87
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/ElementInfo.java93
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/NameValue.java98
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/OptimizedScheduleMessage.java132
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/PolicyInfo.java82
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/SchedulingData.java132
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java6
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java11
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java15
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java10
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java17
-rw-r--r--cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java4
-rw-r--r--cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java43
-rw-r--r--cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterfaceImpl.java49
-rw-r--r--cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java3
-rw-r--r--cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsResponse.java27
-rw-r--r--cmso-ticketmgt/src/main/resources/logmessages.properties2
-rw-r--r--pom.xml1
86 files changed, 2650 insertions, 1268 deletions
diff --git a/cmso-database/etc/config/liquibase.properties b/cmso-database/etc/config/liquibase.properties
index 2454070..e755bf2 100644
--- a/cmso-database/etc/config/liquibase.properties
+++ b/cmso-database/etc/config/liquibase.properties
@@ -1,5 +1,5 @@
###
-# Copyright © 2017-2018 AT&T Intellectual Property.
+# Copyright © 2017-2019 AT&T Intellectual Property.
# Modifications Copyright © 2018 IBM.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,16 +39,5 @@ spring.datasource.tomcat.initialSize=5
spring.datasource.tomcat.max-active=25
spring.datasource.tomcat.test-on-borrow=true
-
-#changeLogFile=calendar-liquibase-changeLog.xml
changeLogFile=cmso-liquibase-changeLog.xml
-
-#spring.main.web-environment=false
-#outputChangeLogFile=src/main/resources/cmso-output-changelog.xml
-#url=jdbc:mariadb://localhost:3306/calendar
-#url=jdbc:mysql://localhost:3306/cmso
-#username=root
-#password=root
-#driver=org.mariadb.jdbc.Driver
-#driver=com.mysql.jdbc.Driver
diff --git a/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-add-uuid.sql b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-add-uuid.sql
new file mode 100644
index 0000000..b11ea0a
--- /dev/null
+++ b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-add-uuid.sql
@@ -0,0 +1,93 @@
+USE CMSO;
+
+-- Schedules Add UUID column
+ALTER TABLE SCHEDULES ADD COLUMN uuid BINARY(16) NOT NULL FIRST;
+-- Add foreign keys
+ALTER TABLE DOMAIN_DATA ADD COLUMN schedules_uuid BINARY(16) NOT NULL;
+ALTER TABLE SCHEDULE_APPROVALS ADD COLUMN schedules_uuid BINARY(16) NOT NULL;
+ALTER TABLE CHANGE_MANAGEMENT_GROUPS ADD COLUMN schedules_uuid BINARY(16) NOT NULL;
+ALTER TABLE CHANGE_MANAGEMENT_CHANGE_WINDOWS ADD COLUMN schedules_uuid BINARY(16);
+
+
+
+-- CHANGE_MANAGEMENT_GROUPS Add UUID column
+ALTER TABLE CHANGE_MANAGEMENT_GROUPS ADD COLUMN uuid BINARY(16) NOT NULL FIRST;
+-- Foreign keys
+ALTER TABLE CHANGE_MANAGEMENT_SCHEDULES ADD COLUMN change_management_group_uuid BINARY(16) NOT NULL;
+ALTER TABLE CHANGE_MANAGEMENT_CHANGE_WINDOWS ADD COLUMN change_management_group_uuid BINARY(16);
+
+
+-- CHANGE_MANAGEMENT_SCHEDULES Add UUID column
+ALTER TABLE CHANGE_MANAGEMENT_SCHEDULES ADD COLUMN uuid BINARY(16) NOT NULL FIRST;
+-- Foreign keys
+
+
+-- DOMAIN_DATA Add UUID column
+ALTER TABLE DOMAIN_DATA ADD COLUMN uuid BINARY(16) NOT NULL FIRST;
+-- Foreign keys
+
+
+-- SCHEDULE_APPROVALS Add UUID column
+ALTER TABLE SCHEDULE_APPROVALS ADD COLUMN uuid BINARY(16) NOT NULL FIRST;
+-- Foreign keys
+
+
+-- CHANGE_MANAGEMENT_CHANGE_WINDOWS Add UUID column
+-- Note that change window will be related to either a schedule or a group.
+ALTER TABLE CHANGE_MANAGEMENT_CHANGE_WINDOWS ADD COLUMN uuid BINARY(16) NOT NULL FIRST;
+-- Foreign keys
+
+
+-- APPROVAL_TYPES Add UUID column
+ALTER TABLE APPROVAL_TYPES ADD COLUMN uuid BINARY(16) NOT NULL FIRST;
+-- Foreign keys
+ALTER TABLE SCHEDULE_APPROVALS ADD COLUMN approval_types_uuid BINARY(16) NOT NULL;
+
+
+-- SCHEDULE_EVENTS not used
+DROP TABLE IF EXISTS SCHEDULE_EVENTS;
+
+SET SQL_SAFE_UPDATES = 0;
+
+-- ----------------------------------------------------
+-- Populate UUID in all existing uuid fields
+-- ----------------------------------------------------
+UPDATE SCHEDULES SET uuid = unhex(replace(uuid(), '-', '')) where uuid is null;
+UPDATE CHANGE_MANAGEMENT_GROUPS SET uuid = unhex(replace(uuid(), '-', '')) where uuid is null;
+UPDATE CHANGE_MANAGEMENT_SCHEDULES SET uuid = unhex(replace(uuid(), '-', '')) where uuid is null;
+UPDATE DOMAIN_DATA SET uuid = unhex(replace(uuid(), '-', '')) where uuid is null;
+UPDATE SCHEDULE_APPROVALS SET uuid = unhex(replace(uuid(), '-', '')) where uuid is null;
+UPDATE CHANGE_MANAGEMENT_CHANGE_WINDOWS SET uuid = unhex(replace(uuid(), '-', '')) where uuid is null;
+UPDATE APPROVAL_TYPES SET uuid = unhex(replace(uuid(), '-', ''));
+
+-- ----------------------------------------------------
+-- SCHEDULES Update all of the foreign key columns
+-- ----------------------------------------------------
+update DOMAIN_DATA set schedules_uuid =
+ (select distinct s.uuid from SCHEDULES s where schedules_id = s.id);
+update SCHEDULE_APPROVALS set schedules_uuid =
+ (select distinct s.uuid from SCHEDULES s where schedules_id = s.id);
+update CHANGE_MANAGEMENT_GROUPS set schedules_uuid =
+ (select distinct s.uuid from SCHEDULES s where schedules_id = s.id);
+
+-- ----------------------------------------------------
+-- CHANGE_MANAGEMENT_GROUPS Update all of the foreign key columns
+-- ----------------------------------------------------
+update CHANGE_MANAGEMENT_SCHEDULES set change_management_group_uuid =
+ (select distinct s.uuid from CHANGE_MANAGEMENT_GROUPS s where change_management_groups_id = s.id);
+update CHANGE_MANAGEMENT_CHANGE_WINDOWS set change_management_group_uuid =
+ (select distinct s.uuid from CHANGE_MANAGEMENT_GROUPS s where change_management_groups_id = s.id);
+
+-- ----------------------------------------------------
+-- APPROVAL_TYPES Update all of the foreign key columns
+-- ----------------------------------------------------
+update SCHEDULE_APPROVALS set approval_types_uuid =
+ (select distinct s.uuid from APPROVAL_TYPES s where approval_type_id = s.id);
+
+-- ----------------------------------------------------
+-- APPROVAL_TYPES Update all of the foreign key columns
+-- ----------------------------------------------------
+update SCHEDULE_APPROVALS set approval_types_uuid =
+ (select distinct s.uuid from SCHEDULE_APPROVALS t, APPROVAL_TYPES s where t.approval_type_id = s.id);
+
+SET SQL_SAFE_UPDATES = 1;
diff --git a/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-drop-ids.sql b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-drop-ids.sql
new file mode 100644
index 0000000..5522f64
--- /dev/null
+++ b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-drop-ids.sql
@@ -0,0 +1,18 @@
+USE CMSO;
+
+-- --------------------------------------------------------------
+-- DROP ALL OF THE INTENGER IDs
+-- --------------------------------------------------------------
+ALTER TABLE SCHEDULES DROP COLUMN id;
+ALTER TABLE DOMAIN_DATA DROP COLUMN id;
+ALTER TABLE DOMAIN_DATA DROP COLUMN schedules_id;
+ALTER TABLE APPROVAL_TYPES DROP COLUMN id;
+ALTER TABLE SCHEDULE_APPROVALS DROP COLUMN id;
+ALTER TABLE SCHEDULE_APPROVALS DROP COLUMN schedules_id;
+ALTER TABLE SCHEDULE_APPROVALS DROP COLUMN approval_type_id;
+ALTER TABLE CHANGE_MANAGEMENT_GROUPS DROP COLUMN id;
+ALTER TABLE CHANGE_MANAGEMENT_GROUPS DROP COLUMN schedules_id;
+ALTER TABLE CHANGE_MANAGEMENT_SCHEDULES DROP COLUMN id;
+ALTER TABLE CHANGE_MANAGEMENT_SCHEDULES DROP COLUMN change_management_groups_id;
+ALTER TABLE CHANGE_MANAGEMENT_CHANGE_WINDOWS DROP COLUMN id;
+ALTER TABLE CHANGE_MANAGEMENT_CHANGE_WINDOWS DROP COLUMN change_management_groups_id;
diff --git a/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-drop-indices.sql b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-drop-indices.sql
new file mode 100644
index 0000000..ec74432
--- /dev/null
+++ b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-drop-indices.sql
@@ -0,0 +1,28 @@
+USE CMSO;
+
+-- -----------------------------------------------------
+-- DROP THE FOREIGN KEYS THAT USE INT IDs
+-- -----------------------------------------------------
+ALTER TABLE DOMAIN_DATA DROP FOREIGN KEY FK_DOMAIN_DATA_SCHEDULES;
+ALTER TABLE SCHEDULE_APPROVALS DROP FOREIGN KEY FK_SCHEDULE_APPROVALS_SCHEDULES;
+ALTER TABLE CHANGE_MANAGEMENT_GROUPS DROP FOREIGN KEY FK_CHANGE_MANAGEMENT_GROUPS_SCHEDULES;
+ALTER TABLE CHANGE_MANAGEMENT_SCHEDULES DROP FOREIGN KEY FK_CHANGE_MANAGEMENT_SCHEDULES_CHANGE_MANAGEMENT_GROUP;
+ALTER TABLE CHANGE_MANAGEMENT_CHANGE_WINDOWS DROP FOREIGN KEY FK_CHANGE_WINDOWS_CHANGE_MANAGEMENT_GROUPS1;
+ALTER TABLE SCHEDULE_APPROVALS DROP FOREIGN KEY FK_SCHEDULE_APPROVALS_APPROVAL_TYPES;
+
+-- -----------------------------------------------------
+-- DROP THE INDEXES THAT USE INT IDs
+-- -----------------------------------------------------
+DROP INDEX ID_UNIQUE ON DOMAIN_DATA; -- THIS iS NOT NECESSARY PK
+DROP INDEX CHANGE_MANAGEMENT_GROUP_ID_UNIQUE ON CHANGE_MANAGEMENT_GROUPS;
+DROP INDEX CHANGE_MANAGEMENT_SCHEDULES_VNF_NAME_UNIQUE ON CHANGE_MANAGEMENT_SCHEDULES;
+DROP INDEX FK_DOMAIN_DATA_SCHEDULES_IDX ON DOMAIN_DATA;
+DROP INDEX FK_SCHEDULE_APPROVALS_SCHEDULES_IDX ON SCHEDULE_APPROVALS;
+DROP INDEX FK_APPROVAL_TYPES_IDX ON SCHEDULE_APPROVALS;
+DROP INDEX FK_SCHEDULES_IDX ON CHANGE_MANAGEMENT_GROUPS;
+DROP INDEX FK_CHANGE_MANAGEMENT_GROUP_CHANGE_MANAGEMENT_SCHEDULES_IDX ON CHANGE_MANAGEMENT_SCHEDULES;
+DROP INDEX FK_CHANGE_WINDOWS_CHANGE_MANAGEMENT_GROUPS1_IDX on CHANGE_MANAGEMENT_CHANGE_WINDOWS;
+
+
+
+
diff --git a/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-restore-indices.sql b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-restore-indices.sql
new file mode 100644
index 0000000..0cb224a
--- /dev/null
+++ b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1.1-restore-indices.sql
@@ -0,0 +1,92 @@
+USE CMSO;
+
+-- -----------------------------------------------------
+-- UPDATE THE PRIMARY KEYS
+-- -----------------------------------------------------
+ALTER TABLE SCHEDULES DROP PRIMARY KEY, CHANGE id id INT, ADD PRIMARY KEY (uuid);
+ALTER TABLE DOMAIN_DATA DROP PRIMARY KEY, CHANGE id id INT, ADD PRIMARY KEY (uuid);
+ALTER TABLE APPROVAL_TYPES DROP PRIMARY KEY, CHANGE id id INT, ADD PRIMARY KEY (uuid);
+ALTER TABLE SCHEDULE_APPROVALS DROP PRIMARY KEY, CHANGE id id INT, ADD PRIMARY KEY (uuid);
+ALTER TABLE CHANGE_MANAGEMENT_GROUPS DROP PRIMARY KEY, CHANGE id id INT, ADD PRIMARY KEY (uuid);
+ALTER TABLE CHANGE_MANAGEMENT_SCHEDULES DROP PRIMARY KEY, CHANGE id id INT, ADD PRIMARY KEY (uuid);
+ALTER TABLE CHANGE_MANAGEMENT_CHANGE_WINDOWS DROP PRIMARY KEY, CHANGE id id INT, ADD PRIMARY KEY (uuid);
+
+-- -----------------------------------------------------
+-- Table CHANGE_MANAGEMENT_DATA (DO this after we update the PK)
+-- -----------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS ELEMENT_DATA (
+ uuid BINARY(16) NOT NULL,
+ change_management_schedules_uuid BINARY(16) NOT NULL,
+ name VARCHAR(128) NULL,
+ value LONGTEXT NULL,
+ CONSTRAINT PK_ELEMENT_DATA PRIMARY KEY (uuid),
+ CONSTRAINT FK_ELEMENT_DATA_CHANGE_MANAGEMENT_SCHEDULES FOREIGN KEY (change_management_schedules_uuid)
+ REFERENCES CHANGE_MANAGEMENT_SCHEDULES (uuid)
+ ON DELETE NO ACTION ON UPDATE NO ACTION
+) ENGINE=INNODB;
+
+CREATE INDEX FK_ELEMENT_DATA_CHANGE_MANAGEMENT_SCHEDULES_IDX ON ELEMENT_DATA (change_management_schedules_uuid ASC);
+
+
+
+
+-- -----------------------------------------------------
+-- RE_CREATE INDEXES WITH UPDATED KEYES
+-- -----------------------------------------------------
+ALTER TABLE DOMAIN_DATA ADD
+ CONSTRAINT FK_DOMAIN_DATA_SCHEDULES FOREIGN KEY (schedules_uuid)
+ REFERENCES SCHEDULES (uuid)
+ ON DELETE NO ACTION ON UPDATE NO ACTION
+;
+CREATE INDEX FK_DOMAIN_DATA_SCHEDULES_IDX ON DOMAIN_DATA (schedules_uuid ASC);
+
+
+-- -----------------------------------------------------
+ALTER TABLE SCHEDULE_APPROVALS ADD
+ CONSTRAINT FK_SCHEDULE_APPROVALS_SCHEDULES FOREIGN KEY (schedules_uuid)
+ REFERENCES SCHEDULES (uuid)
+ ON DELETE NO ACTION ON UPDATE NO ACTION
+;
+ALTER TABLE SCHEDULE_APPROVALS ADD
+ CONSTRAINT FK_SCHEDULE_APPROVALS_APPROVAL_TYPES FOREIGN KEY (approval_types_uuid)
+ REFERENCES APPROVAL_TYPES (uuid)
+ ON DELETE NO ACTION ON UPDATE NO ACTION
+;
+
+CREATE INDEX FK_SCHEDULE_APPROVALS_SCHEDULES_IDX ON SCHEDULE_APPROVALS (schedules_uuid ASC);
+
+CREATE INDEX FK_APPROVAL_TYPES_IDX ON SCHEDULE_APPROVALS (approval_types_uuid ASC);
+
+-- -----------------------------------------------------
+ALTER TABLE CHANGE_MANAGEMENT_GROUPS ADD
+ CONSTRAINT FK_CHANGE_MANAGEMENT_GROUPS_SCHEDULES FOREIGN KEY (schedules_uuid)
+ REFERENCES SCHEDULES (uuid)
+ ON DELETE NO ACTION ON UPDATE NO ACTION
+;
+
+CREATE INDEX FK_SCHEDULES_IDX ON CHANGE_MANAGEMENT_GROUPS (schedules_uuid ASC);
+
+CREATE UNIQUE INDEX CHANGE_MANAGEMENT_GROUP_ID_UNIQUE ON CHANGE_MANAGEMENT_GROUPS (schedules_uuid ASC, group_id ASC);
+
+-- -----------------------------------------------------
+ALTER TABLE CHANGE_MANAGEMENT_SCHEDULES ADD
+ CONSTRAINT FK_CHANGE_MANAGEMENT_SCHEDULES_CHANGE_MANAGEMENT_GROUP FOREIGN KEY (change_management_group_uuid)
+ REFERENCES CHANGE_MANAGEMENT_GROUPS (uuid)
+ ON DELETE NO ACTION ON UPDATE NO ACTION
+;
+
+CREATE INDEX FK_CHANGE_MANAGEMENT_GROUP_CHANGE_MANAGEMENT_SCHEDULES_IDX ON CHANGE_MANAGEMENT_SCHEDULES (change_management_group_uuid ASC);
+
+CREATE UNIQUE INDEX CHANGE_MANAGEMENT_SCHEDULES_VNF_NAME_UNIQUE ON CHANGE_MANAGEMENT_SCHEDULES (change_management_group_uuid ASC, vnf_name ASC);
+
+
+-- -----------------------------------------------------
+ALTER TABLE CHANGE_MANAGEMENT_CHANGE_WINDOWS ADD
+ CONSTRAINT FK_CHANGE_WINDOWS_CHANGE_MANAGEMENT_GROUPS1 FOREIGN KEY (change_management_group_uuid)
+ REFERENCES CHANGE_MANAGEMENT_GROUPS (uuid)
+ ON DELETE NO ACTION ON UPDATE NO ACTION
+;
+
+CREATE INDEX FK_CHANGE_WINDOWS_CHANGE_MANAGEMENT_GROUPS1_IDX on CHANGE_MANAGEMENT_CHANGE_WINDOWS (change_management_group_uuid ASC);
+
diff --git a/cmso-database/src/main/resources/cmso-liquibase-changeLog.xml b/cmso-database/src/main/resources/cmso-liquibase-changeLog.xml
index 0bc23c1..bf45ff9 100644
--- a/cmso-database/src/main/resources/cmso-liquibase-changeLog.xml
+++ b/cmso-database/src/main/resources/cmso-liquibase-changeLog.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
- Copyright © 2017-2018 AT&T Intellectual Property.
+ Copyright © 2017-2019 AT&T Intellectual Property.
Modifications Copyright © 2018 IBM.
Licensed under the Apache License, Version 2.0 (the "License");
@@ -45,4 +45,11 @@
<sqlFile path="cmso-dbchangelog/onap-cmso-v1-schema.sql" />
</changeSet>
+ <changeSet author="ONAP" id="cmso-v1.1-schema1">
+ <sqlFile path="cmso-dbchangelog/onap-cmso-v1.1-drop-indices.sql" />
+ <sqlFile path="cmso-dbchangelog/onap-cmso-v1.1-add-uuid.sql" />
+ <sqlFile path="cmso-dbchangelog/onap-cmso-v1.1-restore-indices.sql" />
+ <sqlFile path="cmso-dbchangelog/onap-cmso-v1.1-drop-ids.sql" />
+ </changeSet>
+
</databaseChangeLog>
diff --git a/cmso-database/src/main/resources/optimizer-dbchanges/onap-optimizer-v1-schema.sql b/cmso-database/src/main/resources/optimizer-dbchanges/onap-optimizer-v1-schema.sql
new file mode 100644
index 0000000..171cb2d
--- /dev/null
+++ b/cmso-database/src/main/resources/optimizer-dbchanges/onap-optimizer-v1-schema.sql
@@ -0,0 +1,54 @@
+CREATE SCHEMA IF NOT EXISTS `optimizer` DEFAULT CHARACTER SET utf8 ;
+
+CREATE TABLE IF NOT EXISTS `optimizer`.`request` (
+ uuid BINARY(16) NOT NULL,
+ request LONGTEXT NOT NULL,
+ created_time BIGINT(20) NULL DEFAULT NULL,
+ request_start BIGINT(20) NULL DEFAULT NULL,
+ request_end BIGINT(20) NULL DEFAULT NULL,
+ status VARCHAR(45) NULL DEFAULT NULL,
+ PRIMARY KEY (`uuid`))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = utf8;
+
+CREATE TABLE IF NOT EXISTS `optimizer`.`response` (
+ uuid BINARY(16) NOT NULL,
+ repsonse LONGTEXT NULL DEFAULT NULL,
+ delivered_time BIGINT(20) NULL DEFAULT NULL,
+ PRIMARY KEY (`uuid`))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = utf8;
+
+
+CREATE TABLE IF NOT EXISTS `optimizer`.`topology` (
+ uuid BINARY(16) NOT NULL,
+ topology LONGTEXT NULL DEFAULT NULL,
+ topology_start BIGINT(20) NULL DEFAULT NULL,
+ topology_end BIGINT(20) NULL DEFAULT NULL,
+ topology_retries INT NULL DEFAULT NULL,
+ topology_polling_interval INT NULL DEFAULT NULL,
+ PRIMARY KEY (`uuid`))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = utf8;
+
+CREATE TABLE IF NOT EXISTS `optimizer`.`tickets` (
+ uuid BINARY(16) NOT NULL,
+ tickets LONGTEXT NULL DEFAULT NULL,
+ tickets_start BIGINT(20) NULL DEFAULT NULL,
+ tickets_end BIGINT(20) NULL DEFAULT NULL,
+ tickets_retries INT NULL DEFAULT NULL,
+ topology_polling_interval INT NULL DEFAULT NULL,
+ PRIMARY KEY (`uuid`))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = utf8;
+
+CREATE TABLE IF NOT EXISTS `optimizer`.`optimizer` (
+ uuid BINARY(16) NOT NULL,
+ optimize_response LONGTEXT NULL DEFAULT NULL,
+ optimize_start BIGINT(20) NULL DEFAULT NULL,
+ optimize_end BIGINT(20) NULL DEFAULT NULL,
+ optimize_retries INT NULL DEFAULT NULL,
+ optimize_polling_interval INT NULL DEFAULT NULL,
+ PRIMARY KEY (`uuid`))
+ENGINE = InnoDB
+DEFAULT CHARACTER SET = utf8;
diff --git a/cmso-database/src/main/resources/optimizer-liquibase-changeLog.xml b/cmso-database/src/main/resources/optimizer-liquibase-changeLog.xml
new file mode 100644
index 0000000..e735975
--- /dev/null
+++ b/cmso-database/src/main/resources/optimizer-liquibase-changeLog.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ Copyright © 2017-2019 AT&T Intellectual Property.
+ Modifications Copyright © 2018 IBM.
+
+ 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.
+
+
+ Unless otherwise specified, all documentation contained herein is licensed
+ under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ you may not use this documentation except in compliance with the License.
+ You may obtain a copy of the License at
+
+ https://creativecommons.org/licenses/by/4.0/
+
+ Unless required by applicable law or agreed to in writing, documentation
+ 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.
+-->
+
+<databaseChangeLog
+ xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
+
+ <changeSet author="ONAP" id="optimizer-v1-schema1">
+ <preConditions onFail="MARK_RAN">
+ <not>
+ <tableExists schemaName="optimizer" tableName="request" />
+ </not>
+ </preConditions>
+ <sqlFile path="optimizer-dbchanges/onap-optimizer-v1-schema.sql" />
+ </changeSet>
+
+</databaseChangeLog>
diff --git a/cmso-robot/.project b/cmso-robot/.project
new file mode 100644
index 0000000..356fc8a
--- /dev/null
+++ b/cmso-robot/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>cmso-robot</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.python.pydev.PyDevBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.robotframework.ide.eclipse.main.plugin.robotLibrariesBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.robotframework.ide.eclipse.main.plugin.robotNature</nature>
+ <nature>org.python.pydev.pythonNature</nature>
+ </natures>
+</projectDescription>
diff --git a/cmso-robot/docker/Dockerfile b/cmso-robot/docker/Dockerfile
index 4fd80d0..b70c16b 100644
--- a/cmso-robot/docker/Dockerfile
+++ b/cmso-robot/docker/Dockerfile
@@ -1,4 +1,4 @@
-FROM ppodgorsek/robot-framework:latest
+FROM robotframework/rfdocker:3.1.1
MAINTAINER "CMSO"
@@ -12,23 +12,6 @@ RUN chmod 777 /opt/cmso-robot/ete.sh
COPY /onap-cmso/server.py /opt/cmso-robot
RUN pip install Flask
-RUN pip install 'PyYAML==3.12'
-RUN pip install 'selenium'
-RUN pip install 'requests'
-RUN pip install 'robotframework-selenium2library'
-RUN pip install 'robotframework-databaselibrary'
-RUN pip install 'robotframework-extendedselenium2library'
-RUN pip install 'robotframework-requests'
-RUN pip install 'robotframework-sshlibrary'
-RUN pip install 'robotframework-sudslibrary'
-RUN pip install 'robotframework-ftplibrary'
-RUN pip install 'robotframework-rammbock'
-RUN pip install 'deepdiff'
-RUN pip install 'dnspython'
-RUN pip install 'robotframework-httplibrary'
-RUN pip install 'robotframework-archivelibrary'
-
-
###Just to keep it running
CMD ["/usr/bin/python", "/opt/cmso-robot/server.py"]
diff --git a/cmso-robot/red.xml b/cmso-robot/red.xml
index 6d935dd..2936755 100644
--- a/cmso-robot/red.xml
+++ b/cmso-robot/red.xml
@@ -1,60 +1,57 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
- Copyright © 2017-2018 AT&T Intellectual Property.
- Modifications Copyright © 2018 IBM.
-
- 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.
-
-
- Unless otherwise specified, all documentation contained herein is licensed
- under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- you may not use this documentation except in compliance with the License.
- You may obtain a copy of the License at
-
- https://creativecommons.org/licenses/by/4.0/
-
- Unless required by applicable law or agreed to in writing, documentation
- 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.
--->
-
-<projectConfiguration>
- <configVersion>1.0</configVersion>
- <robotExecEnvironment path="C:\Python27"/>
- <relativeTo>PROJECT</relativeTo>
- <referencedLibrary type="PYTHON" name="PycURLLibrary" path="cmso-robot/robot/library"/>
- <referencedLibrary type="PYTHON" name="RequestsLibrary" path="cmso-robot/robot/library"/>
- <referencedLibrary type="PYTHON" name="Selenium2Library" path="cmso-robot/robot/library"/>
- <referencedLibrary type="PYTHON" name="selenium" path="cmso-robot/robot/library"/>
- <referencedLibrary type="PYTHON" name="SSHLibrary" path="cmso-robot/robot/library"/>
- <referencedLibrary type="PYTHON" name="HttpLibrary" path="cmso-robot/robot/library"/>
- <referencedLibrary type="PYTHON" name="HttpLibrary.HTTP" path="cmso-robot/robot/library"/>
- <referencedLibrary type="PYTHON" name="StringTemplater" path="cmso-robot/robot/locallibrary/cmsoUtils"/>
- <referencedLibrary type="PYTHON" name="UUID" path="cmso-robot/robot/locallibrary/cmsoUtils"/>
- <referencedLibrary type="PYTHON" name="OSUtils" path="cmso-robot/robot/locallibrary/cmsoUtils"/>
- <referencedLibrary type="PYTHON" name="HTTPUtils" path="cmso-robot/robot/locallibrary/cmsoUtils"/>
- <referencedLibrary type="PYTHON" name="JSONUtils" path="cmso-robot/robot/locallibrary/cmsoUtils"/>
- <pythonpath>
- <path location="robot/library"/>
- </pythonpath>
- <classpath/>
- <variableFiles path="cmso-robot/robot/assets/test_properties.py"/>
- <excludedForValidation/>
- <isValidatedFileSizeCheckingEnabled>true</isValidatedFileSizeCheckingEnabled>
- <validatedFileMaxSize>1024</validatedFileMaxSize>
- <isReferencedLibrariesAutoReloadEnabled>true</isReferencedLibrariesAutoReloadEnabled>
- <isReferencedLibrariesAutoDiscoveringEnabled>true</isReferencedLibrariesAutoDiscoveringEnabled>
- <isLibrariesAutoDiscoveringSummaryWindowEnabled>false</isLibrariesAutoDiscoveringSummaryWindowEnabled>
-</projectConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ Copyright © 2017-2019 AT&T Intellectual Property.
+ Modifications Copyright © 2018 IBM.
+
+ 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.
+
+
+ Unless otherwise specified, all documentation contained herein is licensed
+ under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ you may not use this documentation except in compliance with the License.
+ You may obtain a copy of the License at
+
+ https://creativecommons.org/licenses/by/4.0/
+
+ Unless required by applicable law or agreed to in writing, documentation
+ 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.
+-->
+<projectConfiguration>
+ <configVersion>1</configVersion>
+ <relativeTo>WORKSPACE</relativeTo>
+ <referencedLibrary type="PYTHON" name="RequestsLibrary" path="cmso-robot/library"/>
+ <referencedLibrary type="PYTHON" name="SeleniumLibrary" path="cmso-robot/library"/>
+ <referencedLibrary type="PYTHON" name="selenium" path="cmso-robot/library"/>
+ <referencedLibrary type="PYTHON" name="SSHLibrary" path="cmso-robot/library"/>
+ <referencedLibrary type="PYTHON" name="StringTemplater" path="cmso-robot/robot/locallibrary/cmsoUtils"/>
+ <referencedLibrary type="PYTHON" name="UUID" path="cmso-robot/robot/locallibrary/cmsoUtils"/>
+ <referencedLibrary type="PYTHON" name="OSUtils" path="cmso-robot/robot/locallibrary/cmsoUtils"/>
+ <referencedLibrary type="PYTHON" name="HTTPUtils" path="cmso-robot/robot/locallibrary/cmsoUtils"/>
+ <referencedLibrary type="PYTHON" name="JSONUtils" path="cmso-robot/robot/locallibrary/cmsoUtils"/>
+
+ <pythonpath>
+ <path location="cmso-robot/library"/>
+ </pythonpath>
+ <classpath/>
+ <variableFiles path="cmso-robot/robot/assets/test_properties.py"/>
+
+ <excludedForValidation/>
+ <isValidatedFileSizeCheckingEnabled>true</isValidatedFileSizeCheckingEnabled>
+ <validatedFileMaxSize>1024</validatedFileMaxSize>
+ <isReferencedLibrariesAutoReloadEnabled>true</isReferencedLibrariesAutoReloadEnabled>
+ <isReferencedLibrariesAutoDiscoveringEnabled>true</isReferencedLibrariesAutoDiscoveringEnabled>
+ <isLibrariesAutoDiscoveringSummaryWindowEnabled>false</isLibrariesAutoDiscoveringSummaryWindowEnabled>
+</projectConfiguration>
diff --git a/cmso-robot/robot/assets/sql/selectall.sql b/cmso-robot/robot/assets/sql/selectall.sql
index ba41595..4ffae93 100644
--- a/cmso-robot/robot/assets/sql/selectall.sql
+++ b/cmso-robot/robot/assets/sql/selectall.sql
@@ -1,9 +1,10 @@
-select * from DOMAINS;
-select * from DOMAIN_DATA order by schedules_id desc;
-select * from CHANGE_MANAGEMENT_SCHEDULES order by id desc;
-select * from CHANGE_MANAGEMENT_CHANGE_WINDOWS;
-select * from CHANGE_MANAGEMENT_GROUPS;
-select * from SCHEDULES order by id desc;
-select * from APPROVAL_TYPES;
-select * from SCHEDULE_APPROVALS;
-select * from SCHEDULE_EVENTS; \ No newline at end of file
+select DOMAINS.* from CMSO.DOMAINS;
+select hex(uuid), hex(schedules_uuid), DOMAIN_DATA.* from CMSO.DOMAIN_DATA order by schedules_uuid;
+select hex(uuid), hex(change_management_group_uuid), CHANGE_MANAGEMENT_SCHEDULES.* from CMSO.CHANGE_MANAGEMENT_SCHEDULES order by uuid desc;
+select hex(uuid), hex(schedules_uuid), hex(change_management_group_uuid), CHANGE_MANAGEMENT_CHANGE_WINDOWS.* from CMSO.CHANGE_MANAGEMENT_CHANGE_WINDOWS;
+select hex(uuid), hex(schedules_uuid), CHANGE_MANAGEMENT_GROUPS.* from CMSO.CHANGE_MANAGEMENT_GROUPS;
+select hex(uuid), SCHEDULES.* from CMSO.SCHEDULES order by create_date_time desc;
+select hex(uuid), APPROVAL_TYPES.* from CMSO.APPROVAL_TYPES;
+select hex(uuid), hex(approval_types_uuid), hex(schedules_uuid), SCHEDULE_APPROVALS.* from CMSO.SCHEDULE_APPROVALS;
+select hex(uuid), hex(change_management_schedules_uuid), ELEMENT_DATA.* from CMSO.ELEMENT_DATA;
+
diff --git a/cmso-robot/robot/assets/test_properties.py b/cmso-robot/robot/assets/test_properties.py
index 9afd43d..bced8ba 100644
--- a/cmso-robot/robot/assets/test_properties.py
+++ b/cmso-robot/robot/assets/test_properties.py
@@ -4,8 +4,8 @@ from os.path import isfile, join
# Should be provided in Jenkins job
GLOBAL_SCHEDULER_URL = "http://127.0.0.1:8080"
-GLOBAL_SCHEDULER_USER = "onap-user"
-GLOBAL_SCHEDULER_PASSWORD = "pwd"
+GLOBAL_SCHEDULER_USER = "oof@oof.onap.org"
+GLOBAL_SCHEDULER_PASSWORD = "demo123456!"
GLOBAL_CALLBACK_USERID = "onap-user"
GLOBAL_CALLBACK_PASSWORD = "onap-user"
diff --git a/cmso-robot/robot/locallibrary/cmsoUtils/HTTPUtils.py b/cmso-robot/robot/locallibrary/cmsoUtils/HTTPUtils.py
index f9d380c..8749af8 100644
--- a/cmso-robot/robot/locallibrary/cmsoUtils/HTTPUtils.py
+++ b/cmso-robot/robot/locallibrary/cmsoUtils/HTTPUtils.py
@@ -17,5 +17,5 @@ class HTTPUtils:
def b64_encode(self, instring):
""
- return base64.b64encode(instring)
+ return base64.b64encode(bytes(instring,encoding='utf8'))
diff --git a/cmso-robot/robot/locallibrary/cmsoUtils/JSONUtils.py b/cmso-robot/robot/locallibrary/cmsoUtils/JSONUtils.py
index 5df1e5c..4daccb3 100644
--- a/cmso-robot/robot/locallibrary/cmsoUtils/JSONUtils.py
+++ b/cmso-robot/robot/locallibrary/cmsoUtils/JSONUtils.py
@@ -1,37 +1,11 @@
import json
-from deepdiff import DeepDiff
-
class JSONUtils:
"""JSONUtils is common resource for simple json helper keywords."""
- def json_equals(self, left, right):
- """JSON Equals takes in two strings or json objects, converts them into json if needed and then compares them, returning if they are equal or not."""
- if isinstance(left, basestring):
- left_json = json.loads(left);
- else:
- left_json = left;
- if isinstance(right, basestring):
- right_json = json.loads(right);
- else:
- right_json = right;
-
- ddiff = DeepDiff(left_json, right_json, ignore_order=True);
- if ddiff == {}:
- return True;
- else:
- return False;
def json_escape(self, jsonObject):
jsonstr = json.dumps(jsonObject)
outstr = jsonstr.replace('"', '\\"').replace('\n', '\\n')
return outstr
- def make_list_into_dict(self, listOfDicts, key):
- """ Converts a list of dicts that contains a field that has a unique key into a dict of dicts """
- d = {}
- if isinstance(listOfDicts, list):
- for thisDict in listOfDicts:
- v = thisDict[key]
- d[v] = thisDict
- return d \ No newline at end of file
diff --git a/cmso-robot/robot/resources/browser_setup.robot b/cmso-robot/robot/resources/browser_setup.robot
index 032759e..9361de1 100644
--- a/cmso-robot/robot/resources/browser_setup.robot
+++ b/cmso-robot/robot/resources/browser_setup.robot
@@ -3,7 +3,7 @@ Documentation The main interface for interacting with VID. It handles low le
Library Collections
Library OSUtils
Library OperatingSystem
-Library Selenium2Library
+Library SeleniumLibrary
*** Variables ***
${CHROME_DRIVER_WIN32_PATH} drivers/win32
diff --git a/cmso-robot/robot/resources/files.robot b/cmso-robot/robot/resources/files.robot
index fcfffbb..9ccdd71 100644
--- a/cmso-robot/robot/resources/files.robot
+++ b/cmso-robot/robot/resources/files.robot
@@ -2,7 +2,6 @@
Documentation Some handy Keywords for accessing log files over SSH. Assumptions are that logs will belong to users other than the currently logged in user and that sudo will be required
Library OperatingSystem
Library SSHLibrary
-Library HttpLibrary.HTTP
Library String
Library Collections
diff --git a/cmso-robot/robot/resources/misc.robot b/cmso-robot/robot/resources/misc.robot
index 8409601..d782400 100644
--- a/cmso-robot/robot/resources/misc.robot
+++ b/cmso-robot/robot/resources/misc.robot
@@ -3,7 +3,6 @@ Library Collections
Library String
Library UUID
Library Process
-Library HttpLibrary.HTTP
Documentation Miscellaneous keywords
Resource json_templater.robot
@@ -33,7 +32,7 @@ Check ATTIDs Template
${request_file}= Convert to String OneVnfImmediateATTID.json.template
${attid_file}= OperatingSystem.Get File robot/assets/AOTS_CM_IDs.txt
@{attids}= Split to lines ${attid_file}
- :for ${attid} in @{attids}
+ :for ${attid} IN @{attids}
\ ${uuid}= Generate UUID
\ ${resp}= Run Keyword and Continue on Failure Create Schedule ${uuid} ${request_file} ${template_folder} attid=${attid}
\ Run Keyword and Continue on Failure Should Be Equal as Strings ${resp.status_code} ${expected_status_code}
diff --git a/cmso-robot/robot/resources/scheduler_common.robot b/cmso-robot/robot/resources/scheduler_common.robot
index 0784d71..1256480 100644
--- a/cmso-robot/robot/resources/scheduler_common.robot
+++ b/cmso-robot/robot/resources/scheduler_common.robot
@@ -44,8 +44,8 @@ Post Scheduler
${url}= Catenate ${GLOBAL_SCHEDULER_URL}
${uuid}= Generate UUID
${proxies}= Create Dictionary no=pass
- ${session}= Create Session ${alias} ${url}
- ${auth_string}= B64 Encode ${GLOBAL_SCHEDULER_USER}:${GLOBAL_SCHEDULER_PASSWORD}
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_SCHEDULER_USER}:${GLOBAL_SCHEDULER_PASSWORD}
${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
${resp}= Post Request ${alias} ${data_path} headers=${headers} data=${data}
Log Received response from scheduler ${resp.text}
diff --git a/cmso-robot/robot/resources/scheduler_requests/create_schedule.robot b/cmso-robot/robot/resources/scheduler_requests/create_schedule.robot
index c7b79e7..44443f8 100644
--- a/cmso-robot/robot/resources/scheduler_requests/create_schedule.robot
+++ b/cmso-robot/robot/resources/scheduler_requests/create_schedule.robot
@@ -28,7 +28,7 @@ Create Schedule
${nodelist}= Split String ${NODES} ,
${nn}= Catenate 1
# Support up to 4 ChangeWindows
- : For ${i} in range 1 4
+ : For ${i} IN RANGE 1 4
\ ${today}= Evaluate ((${i}-1)*1440)+${minutesFromNow}
\ ${tomorrow} Evaluate ${today}+1440
\ ${last_time} Evaluate ${today}+30
@@ -36,7 +36,7 @@ Create Schedule
\ ${end_time}= Get Current Date UTC + ${tomorrow} minutes result_format=${UTC}
\ Set To Dictionary ${map} start_time${i}=${start_time} end_time${i}=${end_time}
- : For ${vnf} in @{nodelist}
+ : For ${vnf} IN @{nodelist}
\ Set To Dictionary ${map} node${nn} ${vnf}
\ ${nn}= Evaluate ${nn}+1
diff --git a/cmso-robot/robot/resources/test_templates/change_management.robot b/cmso-robot/robot/resources/test_templates/change_management.robot
index 0584cce..6f4167d 100644
--- a/cmso-robot/robot/resources/test_templates/change_management.robot
+++ b/cmso-robot/robot/resources/test_templates/change_management.robot
@@ -5,7 +5,6 @@ Library String
Library OperatingSystem
Library UUID
Library Collections
-Library HttpLibrary.HTTP
Library DateTime
Resource ../scheduler_common.robot
Resource ../json_templater.robot
@@ -103,14 +102,14 @@ Get Schedule Test Template
${uuid_file}= OperatingSystem.Get File ${existing_uuid_file} #this file works with the dev server as of 11/9/2017
@{file_lines}= Split to Lines ${uuid_file}
&{uuid_dictionary}= Create Dictionary
- :For ${line} in @{file_lines}
+ :For ${line} IN @{file_lines}
\ @{line_array}= Split String ${line}
\ log ${line_array[1]}
\ Set To Dictionary ${uuid_dictionary} @{line_array}[0] @{line_array}[1] #You can pass singular list items as scalar variables
\
Log ${uuid_dictionary}
@{resp_list}= Create List
- :For ${uuid} in @{uuid_dictionary.keys()}
+ :For ${uuid} IN @{uuid_dictionary.keys()}
\ ${resp}= Get Change Management auth schedules/${uuid}
\ ${actual_status}= Get from dictionary ${uuid_dictionary} ${uuid}
\ Should be equal as Strings ${actual_status} ${resp.status_code}
@@ -121,13 +120,13 @@ Wait For All VNFs Reach Status
[Documentation] Checks the status of the VNFs in a schedule.
[Arguments] ${status} ${uuid}
${resp}= Get Change Management auth schedules/scheduleDetails?request.scheduleId=${uuid}
- : for ${vnf} in @{resp.json()}
+ : for ${vnf} IN @{resp.json()}
\ Dictionary Should Contain Item ${vnf} status Completed
Wait For All VNFs Reach Status and Add to Status
[Documentation] This records the status of the vnf in the global status list
[Arguments] ${status} ${uuid}
${resp}= Get Change Management auth schedules/scheduleDetails?request.scheduleId=${uuid}
- : for ${vnf} in @{resp.json()}
+ : for ${vnf} IN @{resp.json()}
\ Dictionary Should Contain Item ${vnf} status Completed
Add to Status List Completed ${uuid} #This only runs if there are no failures in Dictionary should Contain Item for loop previously
Wait for Schedule to Complete
@@ -143,8 +142,8 @@ Add To Status List
[Documentation] Takes List and Schedule ID and changes global list of Statuses #A global list was used because Wait for Keyword to Succeed only seems to return pass or fail
[Arguments] ${end_status} ${uuid}
${resp}= Get Change Management auth schedules/${uuid}
- ${json}= Stringify Json ${resp.json()}
- ${status}= Get Json Value ${json} /status
+ ${json}= Set Variable ${resp.json()}
+ ${status}= Get From Dictionary ${json} status
${temp_list}= Catenate ${status_list} ${status},
${temp_list}= Replace String ${temp_list} ${SPACE}" ${EMPTY}"
Set Global Variable ${status_list} ${temp_list}
@@ -153,7 +152,7 @@ Compare Status List
[Arguments] ${expected} ${actual}
@{expected_list}= Split String ${expected} ,
@{actual_list}= Split String ${actual} ,
- :For ${current} in @{expected_list}
+ :For ${current} IN @{expected_list}
\ Should Contain ${actual_list} ${current}
Change Management DB Failover Template
diff --git a/cmso-robot/robot/resources/test_templates/change_management_ete.robot b/cmso-robot/robot/resources/test_templates/change_management_ete.robot
index 74dfdc2..270d546 100644
--- a/cmso-robot/robot/resources/test_templates/change_management_ete.robot
+++ b/cmso-robot/robot/resources/test_templates/change_management_ete.robot
@@ -43,7 +43,7 @@ Change Management Immediate Template
Wait For All VNFs Reach Status
[Arguments] ${status} ${uuid}
${resp}= Get Change Management auth schedules/scheduleDetails?request.scheduleId=${uuid}
- : for ${vnf} in @{resp.json()}
+ : for ${vnf} IN @{resp.json()}
\ Dictionary Should Contain Item ${vnf} status Completed
Wait for Schedule to Complete
diff --git a/cmso-robot/setup.sh b/cmso-robot/setup.sh
index 1cbd3f9..fa2cc59 100644
--- a/cmso-robot/setup.sh
+++ b/cmso-robot/setup.sh
@@ -6,28 +6,14 @@
# get the path
path=$(pwd)
-pip install --upgrade pip
-pip install --no-cache-dir --target="$path/robot/library" 'selenium<=3.0.0'
-pip install --no-cache-dir --target="$path/robot/library" 'requests==2.11.1'
-pip install --no-cache-dir --target="$path/robot/library" 'robotframework-selenium2library==1.8.0'
-pip install --no-cache-dir --target="$path/robot/library" 'robotframework-databaselibrary==0.8.1'
-pip install --no-cache-dir --target="$path/robot/library" 'robotframework-extendedselenium2library==0.9.1'
-pip install --no-cache-dir --target="$path/robot/library" 'robotframework-requests==0.4.5'
-pip install --no-cache-dir --target="$path/robot/library" 'robotframework-sshlibrary==2.1.2'
-pip install --no-cache-dir --target="$path/robot/library" 'robotframework-sudslibrary==0.8'
-pip install --no-cache-dir --target="$path/robot/library" 'robotframework-ftplibrary==1.3'
-pip install --no-cache-dir --target="$path/robot/library" 'robotframework-rammbock==0.4.0.1'
-pip install --no-cache-dir --target="$path/robot/library" 'deepdiff==2.5.1'
-pip install --no-cache-dir --target="$path/robot/library" 'dnspython==1.15.0'
-pip install --no-cache-dir --target="$path/robot/library" 'robotframework-httplibrary==0.4.2'
-pip install --no-cache-dir --target="$path/robot/library" 'robotframework-archivelibrary==0.3.2'
-pip install --no-cache-dir --target="$path/robot/library" 'PyYAML==3.12'
-
-# NOTE: Patch to incude explicit install of paramiko to 2.0.2 to work with sshlibrary 2.1.2
-# This should be removed on new release of paramiko (2.1.2) or sshlibrary
-# https://github.com/robotframework/SSHLibrary/issues/157
-pip install --no-cache-dir --target="$path/robot/library" -U 'paramiko==2.0.2'
-
+pip install --no-cache-dir --target="$path/library" \
+ 'robotframework' \
+ 'requests' \
+ 'robotframework-requests' \
+ 'selenium' \
+ 'robotframework-seleniumlibrary' \
+ 'robotframework-sshlibrary' \
+ 'paramiko'
#
# Get the appropriate chromedriver. Default to linux64
#
diff --git a/cmso-service/extra/src/main/java/org/onap/optf/utilities/OnapInitialCommit.java b/cmso-service/extra/src/main/java/org/onap/optf/utilities/OnapInitialCommit.java
new file mode 100644
index 0000000..0abf963
--- /dev/null
+++ b/cmso-service/extra/src/main/java/org/onap/optf/utilities/OnapInitialCommit.java
@@ -0,0 +1,297 @@
+/*******************************************************************************
+ * Copyright 2019 AT&T Intellectual Property.
+ *
+ * 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.
+ ******************************************************************************/
+package org.onap.optf.utilities;
+/**
+ * Utility to split a single set of changes into multiple 'micro-commits'. Helpful for initial commits of new components
+ * into the repo
+ *
+ * This will
+ * - determine how many commits are necessary
+ * - create working folders and clone the repo 'N' times
+ * - do git remote add gerrit
+ * - copy each subset of files to the respective working clones
+ * - git add the new (updated?) files
+ * - git commit -m
+ *
+ * Since this is a work in progess the git commit -as and git review are still manual to double check the results
+ *
+ *
+ *
+ *
+ * This code currently assumes a repos structure that containes ONLY the files to be committed. There is no attempt
+ * to identify new/changed files to commit. Preparation of the list of files is manual.
+ *
+ * This does not make any attempt to determine if this will break the build.
+ *
+ * Caution. This code was developed and tested in Windows. WIndows paths to GIT bash, etc. are hard coded.
+ *
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.io.FilenameUtils;
+
+
+
+
+public class OnapInitialCommit
+{
+ CommandLine cmdline = null;
+ Long lpc = 1000l;
+
+ Map<String, Long> fileMap = new TreeMap<String, Long>();
+ List<List<String>> commitLists = new ArrayList<>();
+ public static void main(String []argv)
+ {
+ Options options = new Options();
+ options.addRequiredOption("r", "repoFolder", true, "Folder containing all of the files to commit.");
+ options.addRequiredOption("f", "filesFolder", true, "Folder containing all files to commit - relative to repo folder");
+ options.addRequiredOption("w", "commitReposFolder", true, "Folder where all of the commit repos are created");
+ options.addRequiredOption("c", "cloneCommand", true, "Clone with commit hooks command - with credentials");
+ options.addRequiredOption("g", "remoteAddGerrit", true, "git remote add gerrit command");
+ options.addRequiredOption("i", "issue", true, "Issue ID");
+ options.addRequiredOption("m", "message", true, "Commit message");
+ options.addRequiredOption("p", "clonePath", true, "Path created in commitRepoFolder by the clone command");
+
+ options.addOption("l", "linesPerCommit", true, "lines to commit");
+ CommandLineParser parser = new DefaultParser();
+ try {
+ CommandLine cmd = parser.parse( options, argv);
+ OnapInitialCommit oic = new OnapInitialCommit(cmd);
+ oic.execute();
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp( "OnapIntialCommit", options );
+
+ }
+ }
+
+
+ public OnapInitialCommit(CommandLine cmd)
+ {
+ cmdline = cmd;
+ }
+ private void execute()
+ {
+ buildCommitLists();
+
+ int i = 0;
+ for (List<String> list : commitLists)
+ {
+ i++;
+ commit(list, i);
+ }
+
+ }
+
+
+ private void commit(List<String> list, int i)
+ {
+ if (list.size() == 0)
+ return;
+ System.out.println("\n\n");
+ for (String name : list)
+ {
+ System.out.println(name + ":" + fileMap.get(name));
+ }
+ File cloneFolder = new File(cmdline.getOptionValue("w") + File.separator + "commit" + i);
+ cloneFolder.mkdirs();
+ cloneCode(cloneFolder, i);
+ System.out.println("\n\n");
+ File fromFolder = new File(cmdline.getOptionValue("r"));
+ List<String> filesToAdd = new ArrayList<>();
+ for (String fromFile : list)
+ {
+ String toPath = fromFile.replace(fromFolder.getAbsolutePath(), "");
+
+ Path toFile = Paths.get(cloneFolder + File.separator + "cmso" + toPath);
+ System.out.println(fromFile + ":" + toFile);
+ try {
+ toFile.toFile().mkdirs();
+ Files.copy(Paths.get(fromFile), toFile, StandardCopyOption.REPLACE_EXISTING);
+ filesToAdd.add(toPath);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ commitFiles(cloneFolder, filesToAdd, i);
+ }
+
+
+ private void cloneCode(File cloneFolder, int i)
+ {
+ String unixCloneFolder = FilenameUtils.separatorsToUnix(cloneFolder.getAbsolutePath());
+ unixCloneFolder = unixCloneFolder.replace("c:", "/c");
+ StringBuilder shell = new StringBuilder();
+ shell.append("cd \"").append(unixCloneFolder).append("\"\n");
+ shell.append("export PATH=$PATH:\"/C/Program Files/Git/mingw64/bin\"").append("\n");
+ shell.append(cmdline.getOptionValue("c")).append("\n");
+ shell.append("cd ").append(cmdline.getOptionValue("p")).append("\n");
+ shell.append(cmdline.getOptionValue("g")).append("\n");
+ File shellFile = new File("oic.sh");
+ File shellFileOut = new File("oic.log." + i);
+ try {
+ Files.write(Paths.get(shellFile.getAbsolutePath()), shell.toString().getBytes());
+ String command = "\"C:\\Program Files\\Git\\bin\\bash.exe\" -x " + shellFile.getAbsolutePath();
+
+ ProcessBuilder builder = new ProcessBuilder("C:\\Program Files\\Git\\bin\\bash.exe", "-x", shellFile.getAbsolutePath());
+ builder.redirectOutput(shellFileOut);
+ builder.redirectError(shellFileOut);
+ Process p = builder.start(); // may throw IOException
+ p.waitFor();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+ private void commitFiles(File cloneFolder, List<String> list, int i)
+ {
+ String unixCloneFolder = FilenameUtils.separatorsToUnix(cloneFolder.getAbsolutePath());
+ unixCloneFolder = unixCloneFolder.replace("c:", "/c");
+ StringBuilder shell = new StringBuilder();
+ shell.append("cd \"").append(unixCloneFolder).append("\"\n");
+ shell.append("export PATH=$PATH:\"/C/Program Files/Git/mingw64/bin\"").append("\n");
+ shell.append("cd ").append(cmdline.getOptionValue("p")).append("\n");
+ for (String name : list)
+ {
+ name = FilenameUtils.separatorsToUnix(name);
+ name = name.replaceAll("^/", "");
+ shell.append("git add ").append(name).append("\n");
+ }
+ shell.append("git commit -m \"Commit ").append(i).append(" for ").append(cmdline.getOptionValue("m"));
+ shell.append("\" -m \"Multiple commits required due to commit size limitation.\" -m \"");
+ shell.append("Issue-ID: ").append(cmdline.getOptionValue("i")).append("\"\n");
+
+ File shellFile = new File("addFiles" + i + ".sh");
+ File shellFileOut = new File("addFiles" + i + ".log");
+ try {
+ Files.write(Paths.get(shellFile.getAbsolutePath()), shell.toString().getBytes());
+ String command = "\"C:\\Program Files\\Git\\bin\\bash.exe\" -x " + shellFile.getAbsolutePath();
+
+ ProcessBuilder builder = new ProcessBuilder("C:\\Program Files\\Git\\bin\\bash.exe", "-x", shellFile.getAbsolutePath());
+ builder.redirectOutput(shellFileOut);
+ builder.redirectError(shellFileOut);
+ Process p = builder.start(); // may throw IOException
+ p.waitFor();
+
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+
+
+ private void buildCommitLists()
+ {
+ File files = new File(cmdline.getOptionValue("r") + File.separator + cmdline.getOptionValue("f"));
+ if (files.isDirectory())
+ {
+ buildCommitMap(files);
+ List<String> l = new ArrayList<>();
+ long size = 0;
+ for (String name : fileMap.keySet())
+ {
+ Long thisSize = fileMap.get(name);
+ System.out.println(thisSize + " : " + name);
+ if ((size + thisSize) > lpc )
+ {
+ commitLists.add(l);
+ l = new ArrayList<>();
+ size = 0;
+ }
+ size+=thisSize;
+ l.add(name);
+ }
+ commitLists.add(l);
+ }
+ }
+
+
+ private void buildCommitMap(File files)
+ {
+ for (File thisOne : files.listFiles())
+ {
+ if (thisOne.isDirectory())
+ buildCommitMap(thisOne);
+ else
+ updateMap(thisOne);
+ }
+
+ }
+
+
+ private void updateMap(File thisOne)
+ {
+ //System.out.println(thisOne.getAbsolutePath());
+ Path path = Paths.get(thisOne.getAbsolutePath());
+ long lineCount = -1;
+ Charset[] csList = {
+ StandardCharsets.UTF_8,
+ StandardCharsets.ISO_8859_1,
+ StandardCharsets.US_ASCII,
+ StandardCharsets.UTF_16,
+ };
+ for (Charset cs : csList)
+ {
+ try {
+ lineCount = Files.lines(path, cs).count();
+ if (lineCount > 1)
+ break;
+ } catch (Exception e) {
+ //System.out.println(thisOne.getAbsolutePath());
+ }
+ }
+ if (lineCount > -1)
+ {
+ fileMap.put(thisOne.getAbsolutePath(), lineCount);
+ }
+ else
+ {
+ System.out.println("Skipping " + thisOne.getAbsolutePath());
+ }
+ }
+
+
+}
diff --git a/cmso-service/pom.xml b/cmso-service/pom.xml
index a68744b..d64709e 100644
--- a/cmso-service/pom.xml
+++ b/cmso-service/pom.xml
@@ -56,7 +56,7 @@
<pact.version>3.3.9</pact.version>
<spring.version>5.0.10.RELEASE</spring.version>
<spring.boot.version>2.1.3.RELEASE</spring.boot.version>
- <springfox.swagger2.version>2.9.2</springfox.swagger2.version>
+ <swagger.core.version>2.0.0</swagger.core.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
@@ -65,7 +65,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
<mariadb.version>2.2.1</mariadb.version>
- <swagger.directory>${basedir}/src/main/resources/swagger-ui/dist</swagger.directory>
+ <swagger.directory>${basedir}/src/main/resources/META-INF/resources/swagger/</swagger.directory>
<aaf.version>2.1.4</aaf.version>
<!-- Sonar -->
@@ -230,15 +230,23 @@
<!--Swagger Dependencies -->
<dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>${springfox.swagger2.version}</version>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-jaxrs2</artifactId>
+ <version>${swagger.core.version}</version>
</dependency>
<dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger-ui</artifactId>
- <version>${springfox.swagger2.version}</version>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-jaxrs2-servlet-initializer</artifactId>
+ <version>${swagger.core.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jersey2-jaxrs</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+
+
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java b/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java
index 9b10d51..9189326 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java
@@ -42,7 +42,7 @@ import org.glassfish.jersey.servlet.ServletProperties;
import org.onap.optf.cmso.dispatcher.rs.DispatcherServiceImpl;
import org.onap.optf.cmso.filters.CMSOContainerFilters;
import org.onap.optf.cmso.service.rs.AdminToolImpl;
-import org.onap.optf.cmso.service.rs.CMSCallbackImpl;
+import org.onap.optf.cmso.service.rs.CMSOOptimizerCallbackImpl;
import org.onap.optf.cmso.service.rs.CMSOServiceImpl;
import org.onap.optf.cmso.service.rs.HealthCheckImpl;
import org.onap.optf.cmso.test.loopback.SchedulerTestLoopbackServiceImpl;
@@ -76,7 +76,7 @@ public class JerseyConfiguration extends ResourceConfig {
@Autowired
public JerseyConfiguration( /* LogRequestFilter lrf */ ) {
register(CMSOServiceImpl.class);
- register(CMSCallbackImpl.class);
+ register(CMSOOptimizerCallbackImpl.class);
register(SchedulerTestLoopbackServiceImpl.class);
register(TicketMgtLoopbackServiceImpl.class);
register(HealthCheckImpl.class);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java
index 880566a..f29d6c6 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java
@@ -32,6 +32,7 @@
package org.onap.optf.cmso.dispatcher;
import java.util.Map;
+import java.util.UUID;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -103,19 +104,19 @@ public class CmJob implements Job {
public void execute(JobExecutionContext context) throws JobExecutionException {
Mdc.quartzJobBegin(context);
debug.debug(LogMessages.CM_JOB, "Entered");
- Integer id = context.getJobDetail().getJobDataMap().getInt("key");
+ String id = context.getJobDetail().getJobDataMap().getString("key");
try {
// Hand this off to a transactional service
loopback(id);
} catch (Exception e) {
log.warn("Unexpected exception", e);
} finally {
- dispatchedEventList.remove(id);
+ dispatchedEventList.remove(UUID.fromString(id));
}
debug.debug(LogMessages.CM_JOB, "Exited");
}
- public void loopback(Integer id) {
+ public void loopback(String id) {
Map<String, String> mdcSave = Mdc.save();
try {
String url = env.getProperty("cmso.dispatch.url", "http://localhost:8089");
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java
index cb8597f..60d8bdb 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,8 @@ import java.net.InetAddress;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
+import java.util.UUID;
+
import org.onap.optf.cmso.common.CMSStatusEnum;
import org.onap.optf.cmso.common.LogMessages;
import org.onap.optf.cmso.model.ChangeManagementGroup;
@@ -52,6 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.att.eelf.i18n.EELFResourceManager;
@@ -86,15 +89,15 @@ public class DispatchJob {
@Autowired
Environment env;
- public void execute(Integer id) throws JobExecutionException {
+ public void execute(UUID id) throws JobExecutionException {
debug.debug(LogMessages.CM_JOB, "Entered");
try {
// No other instance can read this cmso until we are done.
ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(id);
cmSchedule.setDispatcherInstance(InetAddress.getLocalHost().getHostAddress());
- ChangeManagementGroup group = cmGroupDAO.findById(cmSchedule.getChangeManagementGroupsId()).orElse(null);
+ ChangeManagementGroup group = cmGroupDAO.findById(cmSchedule.getChangeManagementGroupUuid()).orElse(null);
if (group != null) {
- Schedule schedule = scheduleDAO.findById(group.getSchedulesId()).orElse(null);
+ Schedule schedule = scheduleDAO.findById(group.getSchedulesUuid()).orElse(null);
if (schedule != null) {
schedule.setStatus(CMSStatusEnum.NotificationsInitiated.toString());
if (safeToDispatch(cmSchedule, schedule))
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java
index d0ff299..3c53759 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -58,7 +59,7 @@ public interface DispacherService {
@ApiOperation(value = "", notes = "Does dispsatch of provided cm schedule id.", response = Integer.class)
@ApiResponses(
value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Request failed")})
- public Response dispatchSchedule(@ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") Integer id,
+ public Response dispatchSchedule(@ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") String id,
@Context UriInfo uri, @Context HttpServletRequest request);
// ******************************************************************
@@ -69,7 +70,7 @@ public interface DispacherService {
@ApiResponses(
value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Request failed")})
public Response dispatchOptimizer(
- @ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") Integer id, @Context UriInfo uri,
+ @ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") String id, @Context UriInfo uri,
@Context HttpServletRequest request);
// ******************************************************************
@@ -80,7 +81,7 @@ public interface DispacherService {
@ApiResponses(
value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Request failed")})
public Response dispatchScheduleStatus(
- @ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") Integer id, @Context UriInfo uri,
+ @ApiParam(value = "Identifier", allowMultiple = false) @PathParam("id") String id, @Context UriInfo uri,
@Context HttpServletRequest request);
// ******************************************************************
@@ -90,7 +91,7 @@ public interface DispacherService {
@ApiOperation(value = "", notes = "Does dispsatch of provided cm schedule id.", response = Integer.class)
@ApiResponses(
value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Request failed")})
- public Response dispatchSoStatus(@ApiParam(value = "Identifier", allowMultiple = true) @PathParam("id") Integer id,
+ public Response dispatchSoStatus(@ApiParam(value = "Identifier", allowMultiple = true) @PathParam("id") String id,
@Context UriInfo uri, @Context HttpServletRequest request);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java
index 3aab301..feea350 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java
@@ -31,6 +31,8 @@
package org.onap.optf.cmso.dispatcher.rs;
+import java.util.UUID;
+
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -58,7 +60,7 @@ public class DispatcherServiceImpl implements DispacherService {
DispatchJob dispatchJob;
@Autowired
- CMSOptimizerClient sniroClient;
+ CMSOptimizerClient optimizerClient;
@Autowired
TmStatusClient tmStatusClient;
@@ -68,10 +70,11 @@ public class DispatcherServiceImpl implements DispacherService {
@Override
@Transactional
- public Response dispatchSchedule(Integer id, UriInfo uri, HttpServletRequest request) {
+ public Response dispatchSchedule(String id, UriInfo uri, HttpServletRequest request) {
debug.debug("dispatchSchedule entered {}" , id);
try {
- dispatchJob.execute(id);
+ UUID uuid = UUID.fromString(id);
+ dispatchJob.execute(uuid);
} catch (Exception e) {
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage());
debug.error(e.getMessage(), e);
@@ -82,10 +85,11 @@ public class DispatcherServiceImpl implements DispacherService {
@Override
@Transactional
- public Response dispatchOptimizer(Integer id, UriInfo uri, HttpServletRequest request) {
+ public Response dispatchOptimizer(String id, UriInfo uri, HttpServletRequest request) {
debug.debug("dispatchOptimizer entered {}", id);
try {
- sniroClient.scheduleSniroOptimization(id);
+ UUID uuid = UUID.fromString(id);
+ optimizerClient.scheduleOptimization(uuid);
} catch (Exception e) {
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage());
debug.error(e.getMessage(), e);
@@ -97,7 +101,7 @@ public class DispatcherServiceImpl implements DispacherService {
@Override
@Transactional
- public Response dispatchScheduleStatus(Integer id, UriInfo uri, HttpServletRequest request) {
+ public Response dispatchScheduleStatus(String id, UriInfo uri, HttpServletRequest request) {
debug.debug("dispatchScheduleStatus entered {}", id);
try {
tmStatusClient.checkStatus(id);
@@ -111,7 +115,7 @@ public class DispatcherServiceImpl implements DispacherService {
@Override
@Transactional
- public Response dispatchSoStatus(Integer id, UriInfo uri, HttpServletRequest request) {
+ public Response dispatchSoStatus(String id, UriInfo uri, HttpServletRequest request) {
debug.debug("dispatchSoStatus entered {}", id);
try {
msoStatusClient.execute(id);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java
index 59df59f..0987f8b 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,9 +87,9 @@ public class CMSQueueJob {
return false;
for (ChangeManagementSchedule schedule : schedules) {
try {
- if (!dispatchedEventList.isAlreadyDispatched(schedule.getId())) {
+ if (!dispatchedEventList.isAlreadyDispatched(schedule.getUuid())) {
scheduleCmJob(schedule);
- dispatchedEventList.addToDispathcedEventList(schedule.getId());
+ dispatchedEventList.addToDispathcedEventList(schedule.getUuid());
}
} catch (org.quartz.SchedulerException e) {
debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
@@ -118,7 +118,7 @@ public class CMSQueueJob {
dispatchTime = startTime - dispatherLeadTime;
JobDetail jobDetail = JobBuilder.newJob(CmJob.class).build();
- jobDetail.getJobDataMap().put("key", schedule.getId());
+ jobDetail.getJobDataMap().put("key", schedule.getUuid().toString());
TriggerBuilder<Trigger> tb = TriggerBuilder.newTrigger().forJob(jobDetail);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/DispatchedEventList.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/DispatchedEventList.java
index 0c346d3..3e02cd1 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/DispatchedEventList.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/DispatchedEventList.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,8 @@ package org.onap.optf.cmso.eventq;
import java.util.HashSet;
import java.util.Set;
+import java.util.UUID;
+
import org.springframework.stereotype.Component;
/**
@@ -45,18 +47,18 @@ import org.springframework.stereotype.Component;
@Component
public class DispatchedEventList {
- private Set<Integer> list = new HashSet<>();
+ private Set<UUID> list = new HashSet<>();
- public synchronized void addToDispathcedEventList(Integer id) {
+ public synchronized void addToDispathcedEventList(UUID id) {
list.add(id);
}
- public synchronized void remove(Integer id) {
+ public synchronized void remove(UUID id) {
list.remove(id);
}
- public synchronized boolean isAlreadyDispatched(Integer id) {
- return list.contains(id);
+ public synchronized boolean isAlreadyDispatched(UUID uuid) {
+ return list.contains(uuid);
}
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java
index 121774b..6009040 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java
@@ -32,10 +32,10 @@
package org.onap.optf.cmso.model;
import java.io.Serializable;
+import java.util.UUID;
+
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@@ -51,8 +51,7 @@ public class ApprovalType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private Integer id;
+ private UUID uuid;
@Column(name = "approval_count")
private Integer approvalCount;
@@ -66,15 +65,18 @@ public class ApprovalType implements Serializable {
public ApprovalType() {}
- public Integer getId() {
- return this.id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
+ public UUID getUuid() {
+ return uuid;
+ }
+
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
- public Integer getApprovalCount() {
+ public Integer getApprovalCount() {
return this.approvalCount;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java
index 7224508..210e61a 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java
@@ -32,17 +32,20 @@
package org.onap.optf.cmso.model;
import java.io.Serializable;
+import java.util.UUID;
+
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
+
import org.joda.time.format.ISODateTimeFormat;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -59,8 +62,7 @@ public class ChangeManagementChangeWindow implements Serializable {
@JsonIgnore
@Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private Integer id;
+ private UUID uuid;
@JsonIgnore
@Column(name = "finish_time")
@@ -81,18 +83,11 @@ public class ChangeManagementChangeWindow implements Serializable {
private String startTime;
@JsonIgnore
- @Column(name = "change_management_groups_id")
- private Integer changeManagementGroupsId;
+ @Column(name = "change_management_group_uuid")
+ private UUID changeManagementGroupUuid;
public ChangeManagementChangeWindow() {}
- public Integer getId() {
- return this.id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
public String getFinishTime() {
if (finishTimeMillis != null)
@@ -110,15 +105,29 @@ public class ChangeManagementChangeWindow implements Serializable {
public void setStartTime(String startTime) {}
- public Integer getChangeManagementGroupsId() {
- return changeManagementGroupsId;
- }
- public void setChangeManagementGroupsId(Integer changeManagementGroupsId) {
- this.changeManagementGroupsId = changeManagementGroupsId;
- }
+ public UUID getUuid() {
+ return uuid;
+ }
+
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+
+
+ public UUID getChangeManagementGroupUuid() {
+ return changeManagementGroupUuid;
+ }
+
+
+ public void setChangeManagementGroupUuid(UUID changeManagementGroupUuid) {
+ this.changeManagementGroupUuid = changeManagementGroupUuid;
+ }
+
- public Long getFinishTimeMillis() {
+ public Long getFinishTimeMillis() {
return finishTimeMillis;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java
index 31c4a2b..4f0e804 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java
@@ -31,16 +31,19 @@
package org.onap.optf.cmso.model;
+import java.util.UUID;
+
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Transient;
+
import org.joda.time.format.ISODateTimeFormat;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -59,8 +62,7 @@ import io.swagger.annotations.ApiModelProperty;
public class ChangeManagementDetail {
@Id
@JsonIgnore
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private Integer id;
+ private UUID uuid;
@ApiModelProperty(value = "Name of the VNF.")
@Column(name = "vnf_name")
@@ -168,7 +170,8 @@ public class ChangeManagementDetail {
private String msoTime;
@JsonIgnore
- private Integer schedules_id;
+ @Column(name = "schedules_uuid")
+ private UUID schedulesUuid;
public String getVnfName() {
return vnfName;
@@ -242,15 +245,27 @@ public class ChangeManagementDetail {
this.policyId = policyId;
}
- public Integer getSchedulesId() {
- return schedules_id;
- }
- public void setSchedulesId(Integer schedules_id) {
- this.schedules_id = schedules_id;
- }
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+
+
+
+ public UUID getSchedulesUuid() {
+ return schedulesUuid;
+ }
+
+ public void setSchedulesUuid(UUID schedulesUuid) {
+ this.schedulesUuid = schedulesUuid;
+ }
- public Long getStartTimeMillis() {
+ public Long getStartTimeMillis() {
return startTimeMillis;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java
index 6aeb325..39efb3f 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java
@@ -33,17 +33,20 @@ package org.onap.optf.cmso.model;
import java.io.Serializable;
import java.util.List;
+import java.util.UUID;
+
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
+
import org.joda.time.format.ISODateTimeFormat;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -60,8 +63,7 @@ public class ChangeManagementGroup implements Serializable {
@JsonIgnore
@Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private Integer id;
+ private UUID uuid;
@JsonIgnore
@Column(name = "finish_time")
@@ -95,8 +97,8 @@ public class ChangeManagementGroup implements Serializable {
private String startTime;
@JsonIgnore
- @Column(name = "schedules_id")
- private Integer schedulesId;
+ @Column(name = "schedules_uuid")
+ private UUID schedulesUuid;
@Column(name = "additional_duration_in_secs")
@ApiModelProperty(value = "Time added to the workflow interval to allow for rollback in case of failure.")
@@ -122,13 +124,6 @@ public class ChangeManagementGroup implements Serializable {
public ChangeManagementGroup() {}
- public Integer getId() {
- return this.id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
public String getFinishTime() {
if (finishTimeMillis != null)
@@ -162,13 +157,6 @@ public class ChangeManagementGroup implements Serializable {
public void setStartTime(String startTime) {}
- public Integer getSchedulesId() {
- return schedulesId;
- }
-
- public void setSchedulesId(Integer schedulesId) {
- this.schedulesId = schedulesId;
- }
public Integer getAdditionalDurationInSecs() {
return additionalDurationInSecs;
@@ -234,4 +222,24 @@ public class ChangeManagementGroup implements Serializable {
this.changeManagementSchedules = changeManagementSchedules;
}
+
+ public UUID getUuid() {
+ return uuid;
+ }
+
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+
+ public UUID getSchedulesUuid() {
+ return schedulesUuid;
+ }
+
+
+ public void setSchedulesUuid(UUID schedulesUuid) {
+ this.schedulesUuid = schedulesUuid;
+ }
+
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java
index 9690290..680fc99 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java
@@ -32,18 +32,21 @@
package org.onap.optf.cmso.model;
import java.io.Serializable;
+import java.util.UUID;
+
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
+
import org.joda.time.format.ISODateTimeFormat;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -61,8 +64,7 @@ public class ChangeManagementSchedule implements Serializable {
@JsonIgnore
@Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private Integer id;
+ private UUID uuid;
@ApiModelProperty(value = "TM Change Id")
@Column(name = "tm_change_id")
@@ -107,9 +109,9 @@ public class ChangeManagementSchedule implements Serializable {
@Column(name = "vnf_name")
private String vnfName;
- @Column(name = "change_management_groups_id")
+ @Column(name = "change_management_group_uuid")
@JsonIgnore
- private Integer changeManagementGroupsId;
+ private UUID changeManagementGroupUuid;
@JsonIgnore
@Column(name = "dispatch_time")
@@ -162,14 +164,6 @@ public class ChangeManagementSchedule implements Serializable {
public ChangeManagementSchedule() {}
- public Integer getId() {
- return this.id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
public String getFinishTime() {
if (finishTimeMillis != null)
return ISODateTimeFormat.dateTimeNoMillis().print(finishTimeMillis);
@@ -218,15 +212,25 @@ public class ChangeManagementSchedule implements Serializable {
this.tmChangeId = tmChangeId;
}
- public Integer getChangeManagementGroupsId() {
- return changeManagementGroupsId;
- }
- public void setChangeManagementGroupsId(Integer changeManagementGroupsId) {
- this.changeManagementGroupsId = changeManagementGroupsId;
- }
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+
+ public UUID getChangeManagementGroupUuid() {
+ return changeManagementGroupUuid;
+ }
+
+ public void setChangeManagementGroupUuid(UUID changeManagementGroupUuid) {
+ this.changeManagementGroupUuid = changeManagementGroupUuid;
+ }
- public String getDispatchTime() {
+ public String getDispatchTime() {
if (dispatchTimeMillis != null)
return ISODateTimeFormat.dateTimeNoMillis().print(dispatchTimeMillis);
return null;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java
index fc86964..3bb0bea 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java
@@ -32,15 +32,17 @@
package org.onap.optf.cmso.model;
import java.io.Serializable;
+import java.util.UUID;
+
import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
+
import io.swagger.annotations.ApiModel;
/**
@@ -56,29 +58,31 @@ public class DomainData implements Serializable {
@JsonIgnore
@Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private Integer id;
+ private UUID uuid;
private String name;
private String value;
@ManyToOne(optional = true)
- @JoinColumn(name = "schedules_id", nullable = false, updatable = false)
+ @JoinColumn(name = "schedules_uuid", nullable = false, updatable = false)
@JsonIgnore
private Schedule schedule;
public DomainData() {}
- public Integer getId() {
- return this.id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
+ public UUID getUuid() {
+ return uuid;
+ }
+
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
- public String getName() {
+ public String getName() {
return this.name;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/HelloWorld.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/HelloWorld.java
deleted file mode 100644
index ed09ad7..0000000
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/HelloWorld.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.
- *
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
-*/
-
-package org.onap.optf.cmso.model;
-
-public class HelloWorld {
-
- private String message;
-
- public HelloWorld() {
- // needed for deserializer
- }
-
- public HelloWorld(String message) {
- this.message = message;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- @Override
- public String toString() {
- return "message = " + getMessage();
- }
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java
index d6fe4f9..624e376 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java
@@ -34,22 +34,25 @@ package org.onap.optf.cmso.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
+
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
+
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.joda.time.format.ISODateTimeFormat;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import io.swagger.annotations.ApiModelProperty;
/**
@@ -64,8 +67,7 @@ public class Schedule implements Serializable {
@JsonIgnore
@Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private Integer id;
+ private UUID uuid;
@JsonIgnore
@Column(name = "create_date_time")
@@ -160,15 +162,23 @@ public class Schedule implements Serializable {
public Schedule() {}
- public Integer getId() {
- return this.id;
- }
+ public UUID getUuid() {
+ return uuid;
+ }
- public void setId(Integer id) {
- this.id = id;
- }
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+ public void setDomainData(List<DomainData> domainData) {
+ this.domainData = domainData;
+ }
+
+ public void setScheduleApprovals(List<ScheduleApproval> scheduleApprovals) {
+ this.scheduleApprovals = scheduleApprovals;
+ }
- public String getCreateDateTime() {
+ public String getCreateDateTime() {
if (createDateTimeMillis != null)
return ISODateTimeFormat.dateTimeNoMillis().print(this.createDateTimeMillis);
return null;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java
index dee3c42..3239ae3 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java
@@ -32,19 +32,22 @@
package org.onap.optf.cmso.model;
import java.io.Serializable;
+import java.util.UUID;
+
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
+
import org.joda.time.format.ISODateTimeFormat;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -60,9 +63,8 @@ public class ScheduleApproval implements Serializable {
private static final long serialVersionUID = 1L;
@Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
@JsonIgnore
- private Integer id;
+ private UUID uuid;
@JsonIgnore
@Column(name = "approval_date_time")
@@ -82,23 +84,16 @@ public class ScheduleApproval implements Serializable {
private String userId;
@ManyToOne(optional = true)
- @JoinColumn(name = "schedules_id", nullable = false, updatable = false)
+ @JoinColumn(name = "schedules_uuid", nullable = false, updatable = false)
@JsonIgnore
private Schedule schedule;
@JsonIgnore
- @Column(name = "approval_type_id")
- private Integer approvalTypeId;
+ @Column(name = "approval_types_uuid")
+ private UUID approvalTypesUuid;
public ScheduleApproval() {}
- public Integer getId() {
- return this.id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
public String getApprovalDateTime() {
if (approvalDateTimeMillis != null)
@@ -124,13 +119,6 @@ public class ScheduleApproval implements Serializable {
this.userId = userId;
}
- public Integer getApprovalTypeId() {
- return approvalTypeId;
- }
-
- public void setApprovalTypeId(Integer approvalTypeId) {
- this.approvalTypeId = approvalTypeId;
- }
public void setSchedule(Schedule schedule) {
this.schedule = schedule;
@@ -148,4 +136,26 @@ public class ScheduleApproval implements Serializable {
this.approvalDateTimeMillis = approvalDateTimeMillis;
}
+
+ public UUID getUuid() {
+ return uuid;
+ }
+
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+
+ public UUID getApprovalTypesUuid() {
+ return approvalTypesUuid;
+ }
+
+
+ public void setApprovalTypesUuid(UUID approvalTypesUuid) {
+ this.approvalTypesUuid = approvalTypesUuid;
+ }
+
+
+
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java
deleted file mode 100644
index 46cb46e..0000000
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.
- *
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
-*/
-
-package org.onap.optf.cmso.model;
-
-import java.io.Serializable;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import org.joda.time.format.ISODateTimeFormat;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * The persistent class for the schedule_events database table.
- *
- */
-@Entity
-@Table(name = "SCHEDULE_EVENTS")
-@NamedQuery(name = "ScheduleEvent.findAll", query = "SELECT s FROM ScheduleEvent s")
-public class ScheduleEvent implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- private Integer id;
-
- private String domain;
-
- @Lob
- @Column(name = "event_text")
- private String eventText;
-
- @JsonIgnore
- @Column(name = "event_time")
- private Long eventTimeMillis;
-
- @JsonProperty
- @Transient
- private String eventTime;
-
- @JsonIgnore
- @Column(name = "reminder_time")
- private Long reminderTimeMillis;
-
- @JsonProperty
- @Transient
- private String reminderTime;
-
- @Column(name = "schedules_id")
- private Integer schedulesId;
-
- private String status;
-
- public ScheduleEvent() {}
-
- public Integer getId() {
- return this.id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getDomain() {
- return this.domain;
- }
-
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
- public String getEventText() {
- return this.eventText;
- }
-
- public void setEventText(String eventText) {
- this.eventText = eventText;
- }
-
- public Integer getSchedulesId() {
- return this.schedulesId;
- }
-
- public void setSchedulesId(Integer schedulesId) {
- this.schedulesId = schedulesId;
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public Long getEventTimeMillis() {
- return eventTimeMillis;
- }
-
- public void setEventTimeMillis(Long eventTimeMillis) {
- this.eventTimeMillis = eventTimeMillis;
- }
-
- public String getEventTime() {
- if (eventTimeMillis != null)
- return ISODateTimeFormat.dateTimeNoMillis().print(this.eventTimeMillis);
- return null;
- }
-
- public void setEventTime(String eventTime) {}
-
- public Long getReminderTimeMillis() {
- return reminderTimeMillis;
- }
-
- public void setReminderTimeMillis(Long reminderTimeMillis) {
- this.reminderTimeMillis = reminderTimeMillis;
- }
-
- public String getReminderTime() {
- if (reminderTimeMillis != null)
- return ISODateTimeFormat.dateTimeNoMillis().print(this.reminderTimeMillis);
- return null;
- }
-
- public void setReminderTime(String reminderTime) {}
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleQuery.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleQuery.java
index 84d3e5c..628fc6f 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleQuery.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleQuery.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,8 @@
package org.onap.optf.cmso.model;
+import java.util.UUID;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@@ -38,15 +40,16 @@ import javax.persistence.Id;
@Entity
public class ScheduleQuery {
@Id
- @Column(name = "id")
- private Integer id;
+ @Column(name = "uuid")
+ private UUID uuid;
+
+ public UUID getUuid() {
+ return uuid;
+ }
- public Integer getId() {
- return id;
- }
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
- public void setId(Integer id) {
- this.id = id;
- }
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java
index 7eb2430..9e4b546 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,12 +33,14 @@ package org.onap.optf.cmso.model.dao;
import java.util.List;
import java.util.Optional;
+import java.util.UUID;
+
import org.onap.optf.cmso.model.ApprovalType;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ApprovalTypeDAO extends PagingAndSortingRepository<ApprovalType, Integer> {
- Optional<ApprovalType> findById(Integer id);
+public interface ApprovalTypeDAO extends PagingAndSortingRepository<ApprovalType, UUID> {
+ Optional<ApprovalType> findById(UUID id);
ApprovalType save(ApprovalType persisted);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java
index 293209e..303be20 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,24 +33,26 @@ package org.onap.optf.cmso.model.dao;
import java.util.List;
import java.util.Optional;
+import java.util.UUID;
+
import org.onap.optf.cmso.model.ChangeManagementChangeWindow;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface ChangeManagementChangeWindowDAO
- extends PagingAndSortingRepository<ChangeManagementChangeWindow, Integer> {
- Optional<ChangeManagementChangeWindow> findById(Integer id);
+ extends PagingAndSortingRepository<ChangeManagementChangeWindow, UUID> {
+ Optional<ChangeManagementChangeWindow> findById(UUID id);
ChangeManagementChangeWindow save(ChangeManagementChangeWindow persisted);
void delete(ChangeManagementChangeWindow toDelete);
- @Query(value = "SELECT d FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupsId = ?1")
- List<ChangeManagementChangeWindow> findByGroupsID(Integer id);
+ @Query(value = "SELECT d FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupUuid = ?1")
+ List<ChangeManagementChangeWindow> findByGroupsUUID(UUID id);
@Modifying
- @Query(value = "DELETE FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupsId = ?1")
- int deleteByChangeManagementGroupId(int id);
+ @Query(value = "DELETE FROM ChangeManagementChangeWindow d WHERE d.changeManagementGroupUuid = ?1")
+ int deleteByChangeManagementGroupUuid(UUID id);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java
index 2c083d6..028241c 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ public class ChangeManagementDetailDAOImpl implements ChangeManagementDetailDAO
@Override
public List<ChangeManagementDetail> searchScheduleDetails(String where, int limit) {
StringBuilder sql = new StringBuilder();
- sql.append("select distinct" + " s.id as id," + " s.vnf_name as vnf_name," + " s.vnf_id as vnf_id,"
+ sql.append("select distinct" + " s.uuid as uuid," + " s.vnf_name as vnf_name," + " s.vnf_id as vnf_id,"
+ " s.status as status," + " s.tm_change_id as tm_change_Id," + " s.start_time as start_time,"
+ " s.finish_time as finish_time," + " s.mso_request_id as mso_request_id,"
+ " s.mso_status as mso_status," + " s.mso_message as mso_message," + " s.mso_time as mso_time,"
@@ -54,17 +54,17 @@ public class ChangeManagementDetailDAOImpl implements ChangeManagementDetailDAO
+ " s.status_message as status_message," + " s.tm_approval_status as tm_approval_status,"
+ " s.tm_status as tm_status," + " g.group_id as group_id,"
+ " g.last_instance_start_time as last_instance_start_time," + " g.policy_id as policy_id,"
- + " g.schedules_id as schedules_id"
+ + " g.schedules_uuid as schedules_uuid"
// + " ss.schedule_id as scheduleId,"
// + " dd.name"
+ " from" + " CHANGE_MANAGEMENT_SCHEDULES s"
- + " inner join CHANGE_MANAGEMENT_GROUPS g on s.change_management_groups_id = g.id"
- + " inner join SCHEDULES ss on g.schedules_id = ss.id "
- + " left outer join DOMAIN_DATA dd on ss.id = dd.schedules_id"
- + " left outer join SCHEDULE_APPROVALS sa on ss.id = sa.schedules_id"
- + " left outer join APPROVAL_TYPES at on sa.approval_type_id = at.id ");
+ + " inner join CHANGE_MANAGEMENT_GROUPS g on s.change_management_group_uuid = g.uuid"
+ + " inner join SCHEDULES ss on g.schedules_uuid = ss.uuid "
+ + " left outer join DOMAIN_DATA dd on ss.uuid = dd.schedules_uuid"
+ + " left outer join SCHEDULE_APPROVALS sa on ss.uuid = sa.schedules_uuid"
+ + " left outer join APPROVAL_TYPES at on sa.approval_types_uuid = at.uuid ");
sql.append(where);
- sql.append(" order by id ");
+ sql.append(" order by uuid ");
if (limit > 0)
sql.append("LIMIT " + limit);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java
index 39f4baa..7acc228 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,21 +33,23 @@ package org.onap.optf.cmso.model.dao;
import java.util.List;
import java.util.Optional;
+import java.util.UUID;
+
import org.onap.optf.cmso.model.ChangeManagementGroup;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ChangeManagementGroupDAO extends PagingAndSortingRepository<ChangeManagementGroup, Integer> {
- Optional<ChangeManagementGroup> findById(Integer id);
+public interface ChangeManagementGroupDAO extends PagingAndSortingRepository<ChangeManagementGroup, UUID> {
+ Optional<ChangeManagementGroup> findById(UUID id);
ChangeManagementGroup save(ChangeManagementGroup persisted);
void delete(ChangeManagementGroup toDelete);
- @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesId = ?1")
- List<ChangeManagementGroup> findBySchedulesID(Integer id);
+ @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesUuid = ?1")
+ List<ChangeManagementGroup> findBySchedulesID(UUID id);
- @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesId = ?1 AND d.groupId = ?2")
- ChangeManagementGroup findOneBySchedulesIDGroupID(Integer id, String groupId);
+ @Query(value = "SELECT d FROM ChangeManagementGroup d WHERE d.schedulesUuid = ?1 AND d.groupId = ?2")
+ ChangeManagementGroup findOneBySchedulesIDGroupID(UUID id, String groupId);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java
index a089c2b..ad01a34 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,29 +33,32 @@ package org.onap.optf.cmso.model.dao;
import java.util.List;
import java.util.Optional;
+import java.util.UUID;
+
import javax.persistence.LockModeType;
+
import org.onap.optf.cmso.model.ChangeManagementSchedule;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ChangeManagementScheduleDAO extends PagingAndSortingRepository<ChangeManagementSchedule, Integer> {
- Optional<ChangeManagementSchedule> findById(Integer id);
+public interface ChangeManagementScheduleDAO extends PagingAndSortingRepository<ChangeManagementSchedule, UUID> {
+ Optional<ChangeManagementSchedule> findById(UUID id);
ChangeManagementSchedule save(ChangeManagementSchedule persisted);
void delete(ChangeManagementSchedule toDelete);
- @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupsId = ?1")
- List<ChangeManagementSchedule> findByChangeManagementGroupId(Integer id);
+ @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1")
+ List<ChangeManagementSchedule> findByChangeManagementGroupId(UUID id);
@Modifying
- @Query(value = "DELETE FROM ChangeManagementSchedule d WHERE d.changeManagementGroupsId = ?1")
- public int deleteByChangeManagementGroupsId(Integer id);
+ @Query(value = "DELETE FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1")
+ public int deleteByChangeManagementGroupsId(UUID id);
- @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupsId = ?1 AND d.vnfName = ?2")
- ChangeManagementSchedule findOneByGroupIDAndVnfName(Integer id, String vnfName);
+ @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.changeManagementGroupUuid = ?1 AND d.vnfName = ?2")
+ ChangeManagementSchedule findOneByGroupIDAndVnfName(UUID id, String vnfName);
@Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE (d.status = ?1 AND d.startTimeMillis <= ?2) or d.status = 'Scheduled Immediate' order by d.startTimeMillis")
List<ChangeManagementSchedule> findByStatusAndEndTime(String status, Long date);
@@ -70,8 +73,8 @@ public interface ChangeManagementScheduleDAO extends PagingAndSortingRepository<
@Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.tmApprovalStatus = 'Pending Approval'")
List<ChangeManagementSchedule> findAllAwaitingTmApproval();
- @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.id = ?1")
+ @Query(value = "SELECT d FROM ChangeManagementSchedule d WHERE d.uuid = ?1")
@Lock(LockModeType.PESSIMISTIC_WRITE)
- ChangeManagementSchedule lockOne(Integer id);
+ ChangeManagementSchedule lockOne(UUID id);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java
index 9556938..75299a1 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,11 +32,13 @@
package org.onap.optf.cmso.model.dao;
import java.util.Optional;
+import java.util.UUID;
+
import org.onap.optf.cmso.model.DomainData;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface DomainDataDAO extends PagingAndSortingRepository<DomainData, Integer> {
- Optional<DomainData> findById(Integer id);
+public interface DomainDataDAO extends PagingAndSortingRepository<DomainData, UUID> {
+ Optional<DomainData> findById(UUID id);
DomainData save(DomainData persisted);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java
index d9badd0..3fabd63 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,11 +32,13 @@
package org.onap.optf.cmso.model.dao;
import java.util.Optional;
+import java.util.UUID;
+
import org.onap.optf.cmso.model.ScheduleApproval;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ScheduleApprovalDAO extends PagingAndSortingRepository<ScheduleApproval, Integer> {
- Optional<ScheduleApproval> findById(Integer id);
+public interface ScheduleApprovalDAO extends PagingAndSortingRepository<ScheduleApproval, UUID> {
+ Optional<ScheduleApproval> findById(UUID id);
ScheduleApproval save(ScheduleApproval persisted);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java
index f68fd22..90843c4 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,14 +33,17 @@ package org.onap.optf.cmso.model.dao;
import java.util.List;
import java.util.Optional;
+import java.util.UUID;
+
import javax.persistence.LockModeType;
+
import org.onap.optf.cmso.model.Schedule;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ScheduleDAO extends PagingAndSortingRepository<Schedule, Integer> {
- Optional<Schedule> findById(Integer id);
+public interface ScheduleDAO extends PagingAndSortingRepository<Schedule, UUID> {
+ Optional<Schedule> findById(UUID id);
Schedule save(Schedule persited);
@@ -58,9 +61,9 @@ public interface ScheduleDAO extends PagingAndSortingRepository<Schedule, Intege
@Query(value = "SELECT s FROM Schedule s WHERE s.domain = ?1 AND s.status = 'Notifications Initiated'")
List<Schedule> findAllInProgress(String string);
- @Query(value = "SELECT d FROM Schedule d WHERE d.id = ?1")
+ @Query(value = "SELECT d FROM Schedule d WHERE d.uuid = ?1")
@Lock(LockModeType.PESSIMISTIC_WRITE)
- Schedule lockOne(Integer id);
+ Schedule lockOne(UUID id);
@Query(value = "SELECT s FROM Schedule s WHERE s.optimizerTransactionId= ?1")
@Lock(LockModeType.PESSIMISTIC_WRITE)
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleEventDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleEventDAO.java
deleted file mode 100644
index c3c2483..0000000
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleEventDAO.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.
- *
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
-*/
-
-package org.onap.optf.cmso.model.dao;
-
-import java.util.List;
-import java.util.Optional;
-import org.onap.optf.cmso.model.ScheduleEvent;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.PagingAndSortingRepository;
-
-public interface ScheduleEventDAO extends PagingAndSortingRepository<ScheduleEvent, Integer> {
- Optional<ScheduleEvent> findById(Integer id);
-
- ScheduleEvent save(ScheduleEvent persisted);
-
- void delete(ScheduleEvent toDelete);
-
- @Query(value = "SELECT d FROM ScheduleEvent d WHERE d.schedulesId = ?1")
- List<ScheduleEvent> findByScheduleId(Integer id);
-
- @Query(value = "SELECT d FROM ScheduleEvent d WHERE d.status = ?1 AND d.reminderTimeMillis <= ?2")
- List<ScheduleEvent> findByStatusAndEndTime(String status, Long date);
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java
index 37fbf52..80bb7f0 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,14 +46,14 @@ public class ScheduleQueryDAOImpl implements ScheduleQueryDAO {
@Override
public List<ScheduleQuery> searchSchedules(String where, int limit) {
StringBuilder sql = new StringBuilder();
- sql.append("select distinct" + " ss.id as id" + " from" + " SCHEDULES ss"
- + " left outer join CHANGE_MANAGEMENT_GROUPS g on ss.id = g.schedules_id"
- + " left outer join CHANGE_MANAGEMENT_SCHEDULES s on g.id = s.change_management_groups_id"
- + " left outer join DOMAIN_DATA dd on ss.id = dd.schedules_id"
- + " left outer join SCHEDULE_APPROVALS sa on ss.id = sa.schedules_id"
- + " left outer join APPROVAL_TYPES at on sa.approval_type_id = at.id ");
+ sql.append("select distinct" + " ss.uuid as uuid" + " from" + " SCHEDULES ss"
+ + " left outer join CHANGE_MANAGEMENT_GROUPS g on ss.uuid = g.schedules_uuid"
+ + " left outer join CHANGE_MANAGEMENT_SCHEDULES s on g.uuid = s.change_management_group_uuid"
+ + " left outer join DOMAIN_DATA dd on ss.uuid = dd.schedules_uuid"
+ + " left outer join SCHEDULE_APPROVALS sa on ss.uuid = sa.schedules_uuid"
+ + " left outer join APPROVAL_TYPES at on sa.approval_types_uuid = at.uuid ");
sql.append(where);
- sql.append(" order by id ");
+ sql.append(" order by uuid ");
if (limit > 0)
sql.append("LIMIT " + limit);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java
index 5d500d2..a773798 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java
@@ -85,16 +85,16 @@ public class CMSOptimizerClient {
@Autowired
PropertiesManagement pm;
- public boolean scheduleSniroOptimization(Integer id) {
+ public boolean scheduleOptimization(UUID uuid) {
Map<String, String> mdcSave = Mdc.save();
try {
- String snirourl = env.getProperty("cmso.optimizer.url");
- String snirocallbackurl = env.getProperty("cmso.optimizer.callbackurl");
+ String optimizerurl = env.getProperty("cmso.optimizer.url");
+ String optimizercallbackurl = env.getProperty("cmso.optimizer.callbackurl");
String username = env.getProperty("mechid.user");
- Integer maxAttempts = env.getProperty("cmso.sniro.maxAttempts", Integer.class, 20);
+ Integer maxAttempts = env.getProperty("cmso.optimizer.maxAttempts", Integer.class, 20);
- // Ensure that only one cmso is requsting this call to SNIRO
- Schedule schedule = scheduleDAO.lockOne(id);
+ // Ensure that only one cmso is requsting this call to optimizer
+ Schedule schedule = scheduleDAO.lockOne(uuid);
if (!schedule.getStatus().equals(CMSStatusEnum.PendingSchedule.toString()))
return false;
@@ -116,7 +116,7 @@ public class CMSOptimizerClient {
if (info == null) {
return true;
}
- buildRequest(cmReq, info, schedule, snirocallbackurl);
+ buildRequest(cmReq, info, schedule, optimizercallbackurl);
} catch (Exception e) {
Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
@@ -126,34 +126,34 @@ public class CMSOptimizerClient {
}
// This service will call SNIO for each PendingOptimiztion
- // If the request is successfully scheduled in SNIRO, status will be
+ // If the request is successfully scheduled in optimizer, status will be
// updated to OptimizationInProgress.
Client client = ClientBuilder.newClient();
client.register(new BasicAuthenticatorFilter(username, password));
client.register(new CMSOClientFilters());
- WebTarget sniroTarget = client.target(snirourl);
- Invocation.Builder invocationBuilder = sniroTarget.request(MediaType.APPLICATION_JSON);
+ WebTarget optimizerTarget = client.target(optimizerurl);
+ Invocation.Builder invocationBuilder = optimizerTarget.request(MediaType.APPLICATION_JSON);
try {
//
// First, push OptimizationInProgress to the DB (flush()) assuming a 202 status,
- // in case the SNIRO callback is received prior to the
+ // in case the optimizer callback is received prior to the
// commit of this transaction.
- // SNIRO Callback will throw an error if it receives a response in the incorrect
+ // optimizer Callback will throw an error if it receives a response in the incorrect
// state.
//
schedule.setOptimizerTransactionId(cmReq.getRequestInfo().getTransactionId());
schedule.setOptimizerDateTimeMillis(System.currentTimeMillis());
schedule.setStatus(CMSStatusEnum.OptimizationInProgress.toString());
updateScheduleStatus(schedule);
- debug.debug("SNIRO url / user: " + snirourl + " / " + username);
- debug.debug("SNIRO Request: " + new ObjectMapper().writeValueAsString(cmReq));
- Observation.report(LogMessages.OPTIMIZER_REQUEST, "Begin", schedule.getScheduleId(), snirourl);
+ debug.debug("optimizer url / user: " + optimizerurl + " / " + username);
+ debug.debug("optimizer Request: " + new ObjectMapper().writeValueAsString(cmReq));
+ Observation.report(LogMessages.OPTIMIZER_REQUEST, "Begin", schedule.getScheduleId(), optimizerurl);
Response response = invocationBuilder.post(Entity.json(cmReq));
- Observation.report(LogMessages.OPTIMIZER_REQUEST, "End", schedule.getScheduleId(), snirourl);
+ Observation.report(LogMessages.OPTIMIZER_REQUEST, "End", schedule.getScheduleId(), optimizerurl);
switch (response.getStatus()) {
case 202:
debug.debug("Successfully scheduled optimization: " + schedule.getScheduleId());
- // Scheduled with SNIRO
+ // Scheduled with optimizer
break;
case 400: // Bad request
{
@@ -162,7 +162,7 @@ public class CMSOptimizerClient {
String message = response.readEntity(String.class);
schedule.setOptimizerMessage(message);
schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString());
- // Need to understand the cause of this error. May be teh same as SNIRO
+ // Need to understand the cause of this error. May be teh same as optimizer
// down.
int tries = schedule.getOptimizerAttemptsToSchedule();
tries++;
@@ -195,24 +195,24 @@ public class CMSOptimizerClient {
return true;
} catch (ResponseProcessingException e) {
schedule.setOptimizerDateTimeMillis(System.currentTimeMillis());
- schedule.setOptimizerStatus("Failed to parse SNIRO response");
+ schedule.setOptimizerStatus("Failed to parse optimizer response");
schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString());
- // Need to understand the cause of this error. May be teh same as SNIRO down.
+ // Need to understand the cause of this error. May be teh same as optimizer down.
int tries = schedule.getOptimizerAttemptsToSchedule();
tries++;
schedule.setOptimizerAttemptsToSchedule(tries);
updateScheduleStatus(schedule);
- // Getting invalid response from SNIRO.
+ // Getting invalid response from optimizer.
// May be data related.
Observation.report(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage());
return false;
} catch (ProcessingException e) {
- // Don't track number of retries on IO error (SNIRO is down)
+ // Don't track number of retries on IO error (optimizer is down)
schedule.setOptimizerDateTimeMillis(System.currentTimeMillis());
schedule.setStatus(CMSStatusEnum.PendingSchedule.toString());
updateScheduleStatus(schedule);
- /// Cannot connect to SNIRO
+ /// Cannot connect to optimizer
Observation.report(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage());
// Wait until next cycle
return false;
@@ -226,15 +226,15 @@ public class CMSOptimizerClient {
return false;
}
- private void buildRequest(CMOptimizerRequest cmReq, CMSInfo info, Schedule schedule, String snirocallbackurl) {
+ private void buildRequest(CMOptimizerRequest cmReq, CMSInfo info, Schedule schedule, String optimizercallbackurl) {
- // TODO: Need to get SNIRO to accept ChangeManagementSchedulingInfo
- // This is to support 1707 SNIRO interface
+ // TODO: Need to get optimizer to accept ChangeManagementSchedulingInfo
+ // This is to support 1707 optimizer interface
CMRequestInfo reqInfo = cmReq.getRequestInfo();
CMSchedulingInfo schInfo = cmReq.getSchedulingInfo();
UUID uuid = UUID.randomUUID();
- reqInfo.setCallbackUrl(snirocallbackurl);
+ reqInfo.setCallbackUrl(optimizercallbackurl);
reqInfo.setOptimizer(new String[] {"scheduling"});
reqInfo.setTransactionId(schedule.getOptimizerTransactionId());
reqInfo.setRequestId("CM-" + uuid.toString());
@@ -283,7 +283,7 @@ public class CMSOptimizerClient {
// Perhaps We create ChangeManagementSchedulingInfoV1, ...V2, etc.
// ANd try them one after another....
Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, "Unable to parse message. Format changed?");
- schedule.setOptimizerStatus("Failed to parse SNIRO request");
+ schedule.setOptimizerStatus("Failed to parse optimizer request");
schedule.setOptimizerDateTimeMillis(System.currentTimeMillis());
schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
scheduleDAO.save(schedule);
@@ -300,12 +300,12 @@ public class CMSOptimizerClient {
public HealthCheckComponent healthCheck() {
Map<String, String> mdcSave = Mdc.save();
HealthCheckComponent hcc = new HealthCheckComponent();
- hcc.setName("SNIRO Interface");
- String snirourl = env.getProperty("cmso.optimizer.url");
- String snirocallbackurl = env.getProperty("cmso.optimizer.callbackurl");
+ hcc.setName("OPtimizer Interface");
+ String optimizerurl = env.getProperty("cmso.optimizer.url");
+ String optimizercallbackurl = env.getProperty("cmso.optimizer.callbackurl");
String username = env.getProperty("mechid.user");
String password = pm.getProperty("mechid.pass", "");
- hcc.setUrl(snirourl);
+ hcc.setUrl(optimizerurl);
try {
UUID uuid = UUID.randomUUID();
// Build a bogus request should fail policy validation
@@ -335,22 +335,22 @@ public class CMSOptimizerClient {
client.register(new BasicAuthenticatorFilter(username, password));
client.register(new CMSOClientFilters());
- WebTarget sniroTarget = client.target(snirourl);
- Invocation.Builder invocationBuilder = sniroTarget.request(MediaType.APPLICATION_JSON);
- debug.debug("SNIRO url / user: " + snirourl + " / " + username);
- Observation.report(LogMessages.OPTIMIZER_REQUEST, "Begin", "healthcheck", snirourl);
+ WebTarget optimizerTarget = client.target(optimizerurl);
+ Invocation.Builder invocationBuilder = optimizerTarget.request(MediaType.APPLICATION_JSON);
+ debug.debug("Optimizer url / user: " + optimizerurl + " / " + username);
+ Observation.report(LogMessages.OPTIMIZER_REQUEST, "Begin", "healthcheck", optimizerurl);
Response response = invocationBuilder.post(Entity.json(cmReq));
- Observation.report(LogMessages.OPTIMIZER_REQUEST, "End", "healthcheck", snirourl);
+ Observation.report(LogMessages.OPTIMIZER_REQUEST, "End", "healthcheck", optimizerurl);
String message = response.getStatus() + ":" + response.readEntity(String.class);
switch (response.getStatus()) {
case 202:
- debug.debug("Successful SNIRO healthcheck");
+ debug.debug("Successful optimizer healthcheck");
hcc.setHealthy(true);
break;
case 400:
// Expecting policy not found.
if (message.contains("Cannot fetch policy")) {
- debug.debug("Successful SNIRO healthcheck");
+ debug.debug("Successful optimizer healthcheck");
hcc.setHealthy(true);
hcc.setStatus("OK");
} else {
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java
index 39d590b..12d56f3 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java
@@ -33,6 +33,8 @@ package org.onap.optf.cmso.optimizer;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
+
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
@@ -57,6 +59,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -107,7 +110,7 @@ public class OptimizerQuartzJob extends QuartzJobBean {
}
public void scheduleOptimization(Schedule s) {
- Integer id = s.getId();
+ UUID id = s.getUuid();
Map<String, String> mdcSave = Mdc.save();
try {
String url = env.getProperty("cmso.dispatch.url", "http://localhost:8089");
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java
index a50025b..6dd7bdf 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java
index 801986c..10eedf8 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,23 +31,21 @@
package org.onap.optf.cmso.service.rs;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-@Api
+@Api("CMSO Administration")
@Path("/{apiVersion}")
@Produces({MediaType.APPLICATION_JSON})
public interface AdminTool {
@@ -60,7 +58,6 @@ public interface AdminTool {
@ApiResponses(
value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Request failed")})
public Response exec(@ApiParam(value = "v1|v2") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
- @ApiParam(value = "Identifier", allowMultiple = true) @PathParam("id") String id, @Context UriInfo uri,
- @Context HttpServletRequest request);
+ @ApiParam(value = "Identifier", allowMultiple = true) @PathParam("id") String id);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java
index b878d31..8ec4f4f 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java
@@ -31,32 +31,38 @@
package org.onap.optf.cmso.service.rs;
-import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.onap.observations.Mdc;
import org.onap.optf.cmso.common.PropertiesManagement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@Controller
public class AdminToolImpl implements AdminTool {
private static EELFLogger log = EELFManager.getInstance().getLogger(AdminToolImpl.class);
- private static EELFLogger audit = EELFManager.getInstance().getAuditLogger();
+
+ @Context
+ UriInfo uri;
+
+ @Context
+ HttpServletRequest request;
+
@Autowired
PropertiesManagement pm;
@Override
- public Response exec(String apiVersion, String id, UriInfo uri, HttpServletRequest request) {
+ public Response exec(String apiVersion, String id) {
log.info("AdminTool.exec entered");
if (id.length() < 4)
return Response.ok("").build();
- String encrypted = pm.getEncryptedValue(id);
+ String encrypted = PropertiesManagement.getEncryptedValue(id);
Response response = Response.ok(encrypted).build();
return response;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java
index 2e0cfeb..787bd60 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java
@@ -35,7 +35,10 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
+
import javax.ws.rs.core.Response.Status;
+
import org.onap.optf.cmso.common.ApprovalStatusEnum;
import org.onap.optf.cmso.common.CMSStatusEnum;
import org.onap.optf.cmso.common.LogMessages;
@@ -54,6 +57,7 @@ import org.onap.optf.cmso.service.rs.models.ApprovalMessage;
import org.onap.optf.cmso.service.rs.models.ScheduleMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -82,6 +86,7 @@ public class BaseSchedulerServiceImpl {
throw new CMSAlreadyExistsException(scheduleMessage.getDomain(), scheduleMessage.getScheduleId());
}
s = new Schedule();
+ s.setUuid(UUID.randomUUID());
s.setUserId(scheduleMessage.getUserId());
s.setCreateDateTimeMillis(System.currentTimeMillis());
s.setDomain(scheduleMessage.getDomain());
@@ -96,6 +101,7 @@ public class BaseSchedulerServiceImpl {
s.setStatus(CMSStatusEnum.PendingSchedule.toString());
scheduleDAO.save(s);
for (DomainData dd : domainData) {
+ dd.setUuid(UUID.randomUUID());
s.addDomainData(dd);
domainDataDAO.save(dd);
}
@@ -153,15 +159,16 @@ public class BaseSchedulerServiceImpl {
if (s.getScheduleApprovals() != null) {
for (ScheduleApproval scheduleApproval : s.getScheduleApprovals()) {
if (scheduleApproval.getUserId().equals(approvalMessage.getApprovalUserId())
- && scheduleApproval.getApprovalTypeId().equals(approvalType.getId())) {
+ && scheduleApproval.getApprovalTypesUuid().equals(approvalType.getUuid())) {
sa = scheduleApproval;
}
}
}
if (sa == null) {
sa = new ScheduleApproval();
+ sa.setUuid(UUID.randomUUID());
sa.setSchedule(s);
- sa.setApprovalTypeId(approvalType.getId());
+ sa.setApprovalTypesUuid(approvalType.getUuid());
sa.setUserId(approvalMessage.getApprovalUserId());
}
// Ignore what time is on the message
@@ -181,18 +188,18 @@ public class BaseSchedulerServiceImpl {
}
private boolean allApprovalsReceived(Schedule schedule, ScheduleApproval sa) {
- Map<Integer, Integer> requiredApprovalsByType = new HashMap<Integer, Integer>(); // Approval
+ Map<UUID, Integer> requiredApprovalsByType = new HashMap<>(); // Approval
// countdown
- Map<Integer, ApprovalType> approvalsByType = new HashMap<Integer, ApprovalType>(); // Just
+ Map<UUID, ApprovalType> approvalsByType = new HashMap<>(); // Just
// for
// logging
List<ApprovalType> approvalTypes = approvalTypeDAO.findByDomain(schedule.getDomain());
for (ApprovalType at : approvalTypes) {
- Integer type = at.getId();
+ UUID type = at.getUuid();
Integer count = at.getApprovalCount();
requiredApprovalsByType.put(type, count);
- approvalsByType.put(at.getId(), at);
+ approvalsByType.put(at.getUuid(), at);
}
// Account for approvals so far
@@ -205,17 +212,17 @@ public class BaseSchedulerServiceImpl {
}
for (ScheduleApproval approval : existingApprovals) {
if (approval.getStatus().equals(ApprovalStatusEnum.Accepted.toString())) {
- Integer remaining = requiredApprovalsByType.get(approval.getApprovalTypeId());
+ Integer remaining = requiredApprovalsByType.get(approval.getApprovalTypesUuid());
if (remaining != null) {
remaining = remaining - 1;
- requiredApprovalsByType.put(approval.getApprovalTypeId(), remaining);
+ requiredApprovalsByType.put(approval.getApprovalTypesUuid(), remaining);
} else {
- log.warn("Ignored Unidentified approval type {0} for domain {1}", approval.getApprovalTypeId(),
+ log.warn("Ignored Unidentified approval type {0} for domain {1}", approval.getApprovalTypesUuid(),
schedule.getDomain());
}
}
}
- for (Integer id : requiredApprovalsByType.keySet()) {
+ for (UUID id : requiredApprovalsByType.keySet()) {
Integer remaining = requiredApprovalsByType.get(id);
if (remaining > 0) {
return false;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java
new file mode 100644
index 0000000..c0806d7
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleService.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.
+*/
+
+package org.onap.optf.cmso.service.rs;
+
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onap.optf.cmso.common.CMSRequestError;
+import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+@Api("CMSO Optimized Schedule API")
+@Path("/{apiVersion}")
+@Produces({MediaType.APPLICATION_JSON})
+public interface CMSOOptimizedScheduleService {
+
+ // ******************************************************************
+ @POST
+ @Path("/schedules/optimized/{scheduleId}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "", notes = "Creates a request for an optimized schedule")
+ @ApiResponses(
+ value = {@ApiResponse(code = 202, message = "Schedule request accepted for optimization."),
+ @ApiResponse(code = 409, message = "Schedule request already exists for this schedule id.",
+ response = CMSRequestError.class),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ public Response createScheduleRequest(
+ @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
+ @ApiParam(
+ value = "Schedule id to uniquely identify the schedule request being created.") @PathParam("scheduleId") String scheduleId,
+ @ApiParam(
+ value = "Data for creating a schedule request for the given schedule id") OptimizedScheduleMessage scheduleMessage);
+
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java
new file mode 100644
index 0000000..aa397ae
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizedScheduleServiceImpl.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright © 2017-2019 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.
+*/
+
+package org.onap.optf.cmso.service.rs;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.onap.observations.Observation;
+import org.onap.optf.cmso.common.LogMessages;
+import org.onap.optf.cmso.common.exceptions.CMSException;
+import org.onap.optf.cmso.eventq.CMSQueueJob;
+import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
+import org.onap.optf.cmso.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.model.dao.ScheduleQueryDAO;
+import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;
+import org.onap.optf.cmso.ticketmgt.TmClient;
+import org.onap.optf.cmso.ticketmgt.bean.BuildCreateRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Controller;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+@Controller
+public class CMSOOptimizedScheduleServiceImpl implements CMSOOptimizedScheduleService {
+ private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
+
+ @Autowired
+ CMSQueueJob qJob;
+
+ @Autowired
+ Environment env;
+
+ @Autowired
+ ChangeManagementScheduleDAO cmScheduleDAO;
+
+ @Autowired
+ ChangeManagementGroupDAO cmGroupDAO;
+
+ @Autowired
+ ChangeManagementChangeWindowDAO cmChangeWindowDAO;
+
+ @Autowired
+ ChangeManagementDetailDAO cmDetailsDAO;
+
+ @Autowired
+ ScheduleQueryDAO scheduleQueryDAO;
+
+ @Autowired
+ ScheduleDAO scheduleDAO;
+
+ @Autowired
+ TmClient tmClient;
+
+ @Autowired
+ BuildCreateRequest buildCreateRequest;
+
+
+ @Context
+ HttpServletRequest request;
+
+ @Override
+ @Transactional
+ public Response createScheduleRequest(String apiVersion, String scheduleId, OptimizedScheduleMessage scheduleMessage)
+ {
+ Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId,
+ scheduleMessage.toString());
+ Response response = null;
+ try {
+ response = Response.accepted().build();
+// } catch (CMSException e) {
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
+// response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ response = Response.serverError().build();
+ }
+ Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId,
+ response.getStatusInfo().toString());
+ return response;
+ }
+
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSCallbackImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java
index 5d11225..50d2ff2 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSCallbackImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java
@@ -1,260 +1,269 @@
-/*
- * Copyright © 2017-2019 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.
- *
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
-*/
-
-package org.onap.optf.cmso.service.rs;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.transaction.Transactional;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriInfo;
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.ISODateTimeFormat;
-import org.onap.observations.Mdc;
-import org.onap.optf.cmso.common.CMSStatusEnum;
-import org.onap.optf.cmso.common.DomainsEnum;
-import org.onap.optf.cmso.common.LogMessages;
-import org.onap.optf.cmso.common.exceptions.CMSException;
-import org.onap.optf.cmso.common.exceptions.CMSNotFoundException;
-import org.onap.optf.cmso.model.ChangeManagementGroup;
-import org.onap.optf.cmso.model.ChangeManagementSchedule;
-import org.onap.optf.cmso.model.Schedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
-import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse;
-import org.onap.optf.cmso.optimizer.bean.CMSchedule;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@Controller
-public class CMSCallbackImpl extends BaseSchedulerServiceImpl implements CMSOptimizerCallback {
- private static EELFLogger log = EELFManager.getInstance().getLogger(CMSCallbackImpl.class);
- private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger();
- private static EELFLogger audit = EELFManager.getInstance().getAuditLogger();
- private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
- private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
-
- @Autowired
- ChangeManagementScheduleDAO cmScheduleDAO;
-
- @Autowired
- ChangeManagementGroupDAO cmGroupDAO;
-
- @Autowired
- ChangeManagementChangeWindowDAO cmChangeWindowDAO;
-
- @Autowired
- ChangeManagementDetailDAO cmDetailsDAO;
-
- @Override
- @Transactional
- public Response sniroCallback(String apiVersion, CMOptimizerResponse sniroResponse, UriInfo uri,
- HttpServletRequest request) {
- Response response = null;
- log.info(LogMessages.PROCESS_OPTIMIZER_CALLBACK, "Received", request.getRemoteAddr(), "");
- log.info(LogMessages.OPTIMIZER_REQUEST, "Callback received", sniroResponse.getTransactionId(),
- uri.getAbsolutePath().toString());
- try {
- // Note that transaction ID and schedule ID are currently the same value.
-
- String transactionId = sniroResponse.getTransactionId();
-
- // Synchronize this with transaction that scheduled the SNIRO optimization
- // to ensure status updates are properly ordered.
- // This is necessary only in the race condition where SNIRO callback comes
- // before the SNIRO response is processed and the scheduling transaction is
- // still in flight.
- // Note that this may happen in loopback mode, but is not likely to happen with
- // real SNIRO unless SNIRO changes to be synchronous and the callback comes before
- // the response.
- // If this lock times out, the schedule will remain in 'Optimization In
- // Progress' and never complete.
- Schedule schedule = scheduleDAO.lockOneByTransactionId(transactionId);
-
- if (schedule == null) {
- throw new CMSNotFoundException(DomainsEnum.ChangeManagement.toString(),
- "(OptimizerTransactionID=" + transactionId + ")");
-
- }
- CMSStatusEnum status = CMSStatusEnum.PendingApproval.fromString(schedule.getStatus());
- debug.debug("Status at time of SNIRO callback is " + status.toString());
- switch (status) {
- // PendingSchedule may be a valid status in the cases where SNIRO async call
- // returns before
- // We have committed the OptimizationInProgress status
- // The dispatch logic ensures that we only every dispatch once.
- case OptimizationInProgress:
- processSniroResponse(sniroResponse, schedule);
- scheduleDAO.save(schedule);
- response = Response.ok().build();
- break;
- default:
- throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR,
- CMSStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString());
- }
- } catch (CMSException e) {
- errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
- } catch (Exception e) {
- errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- response = Response.serverError().entity(e.getMessage()).build();
- } finally {
- }
- return response;
- }
-
- private void processSniroResponse(CMOptimizerResponse sniroResponse, Schedule schedule) {
- try {
- schedule.setOptimizerReturnDateTimeMillis(System.currentTimeMillis());
- schedule.setOptimizerStatus(sniroResponse.getRequestState());
- schedule.setOptimizerMessage(sniroResponse.getDescription());
- String scheduleId = sniroResponse.getScheduleId();
- ObjectMapper om = new ObjectMapper();
- CMSchedule[] scheduleArray = sniroResponse.getSchedule();
- if (scheduleArray != null && scheduleArray.length > 0) {
- String scheduleString = om.writeValueAsString(scheduleArray);
- schedule.setSchedule(scheduleString);
- log.debug("scheduleId={0} schedule={1}", scheduleId, scheduleString);
- for (CMSchedule sniroSchedule : sniroResponse.getSchedule()) {
- String groupId = sniroSchedule.getGroupId();
- DateTime finishTime = convertDate(sniroSchedule.getFinishTime(), "finishTime");
- DateTime latestInstanceStartTime =
- convertDate(sniroSchedule.getLatestInstanceStartTime(), "latestInstanceStartTime");
- DateTime startTime = convertDate(sniroSchedule.getStartTime(), "startTime");
- ChangeManagementGroup group = cmGroupDAO.findOneBySchedulesIDGroupID(schedule.getId(), groupId);
- if (group == null) {
- throw new CMSException(Status.PRECONDITION_FAILED,
- LogMessages.CHANGE_MANAGEMENT_GROUP_NOT_FOUND, schedule.getScheduleId(), groupId);
- }
- group.setStartTimeMillis(startTime.getMillis());
- group.setFinishTimeMillis(finishTime.getMillis());
- group.setLastInstanceStartTimeMillis(latestInstanceStartTime.getMillis());
- cmGroupDAO.save(group);
- long totalDuration =
- (group.getAdditionalDurationInSecs() + group.getNormalDurationInSecs()) * 1000l;
- Map<String, Map<String, Long>> startAndFinishTimeMap = new HashMap<String, Map<String, Long>>();
- makeMap(startTime.getMillis(), latestInstanceStartTime.getMillis(), group.getConcurrencyLimit(),
- totalDuration, sniroSchedule.getNode(), startAndFinishTimeMap);
- for (String node : sniroSchedule.getNode()) {
- processNode(schedule, group, node, startAndFinishTimeMap);
- }
- }
- schedule.setStatus(CMSStatusEnum.PendingApproval.toString());
- } else {
- debug.debug("scheduleId={0} schedule=null status={1} ", scheduleId, schedule.getOptimizerStatus());
- schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
- }
- } catch (CMSException e) {
- errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
- schedule.setOptimizerStatus(e.getStatus().toString());
- schedule.setOptimizerMessage(e.getLocalizedMessage());
- } catch (Exception e) {
- errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
- schedule.setOptimizerStatus("Exception");
- schedule.setOptimizerMessage(e.getLocalizedMessage());
- }
- }
-
- public static void makeMap(Long startTime, Long latestInstanceStartTime, int concurrencyLimit, long totalDuration,
- List<String> nodes, Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException {
- Long nextStartTime = null;
- Long nextFinishTime = null;
- for (int nodeNumber = 0; nodeNumber < nodes.size(); nodeNumber++) {
- String node = nodes.get(nodeNumber);
- if (nodeNumber % concurrencyLimit == 0) {
- if (nodeNumber == 0)
- nextStartTime = startTime;
- else
- nextStartTime = nextStartTime + totalDuration;
- if (nextStartTime > latestInstanceStartTime) {
- throw new CMSException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS,
- startTime.toString(), latestInstanceStartTime.toString(), String.valueOf(totalDuration),
- String.valueOf(concurrencyLimit), String.valueOf(nodes.size()));
- }
- nextFinishTime = nextStartTime + totalDuration;
- }
- Map<String, Long> map = new HashMap<String, Long>();
- map.put("startTime", nextStartTime);
- map.put("finishTime", nextFinishTime);
- startAndFinishTimeMap.put(node, map);
- }
-
- }
-
- private void processNode(Schedule schedule, ChangeManagementGroup group, String node,
- Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException {
- Map<String, Long> map = startAndFinishTimeMap.get(node);
- ChangeManagementSchedule detail = cmScheduleDAO.findOneByGroupIDAndVnfName(group.getId(), node);
- if (detail == null) {
- throw new CMSException(Status.NOT_FOUND, LogMessages.UNABLE_TO_LOCATE_SCHEDULE_DETAIL,
- schedule.getScheduleId(), group.getGroupId(), node);
- }
- detail.setStartTimeMillis(map.get("startTime"));
- detail.setFinishTimeMillis(map.get("finishTime"));
- detail.setVnfId("");
- detail.setStatus(CMSStatusEnum.PendingApproval.toString());
- cmScheduleDAO.save(detail);
- }
-
- public static DateTime convertDate(String utcDate, String attrName) throws CMSException {
- try {
- DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC().parseDateTime(utcDate);
- if (dateTime != null)
- return dateTime;
- } catch (Exception e) {
- debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- }
- throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate);
- }
-
- public static DateTime convertISODate(String utcDate, String attrName) throws CMSException {
- try {
- DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate);
- if (dateTime != null)
- return dateTime;
- } catch (Exception e) {
- debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- }
- throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate);
- }
-
-}
+/*
+ * Copyright © 2017-2019 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.
+*/
+
+package org.onap.optf.cmso.service.rs;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.transaction.Transactional;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.ISODateTimeFormat;
+import org.onap.optf.cmso.common.CMSStatusEnum;
+import org.onap.optf.cmso.common.DomainsEnum;
+import org.onap.optf.cmso.common.LogMessages;
+import org.onap.optf.cmso.common.exceptions.CMSException;
+import org.onap.optf.cmso.common.exceptions.CMSNotFoundException;
+import org.onap.optf.cmso.model.ChangeManagementGroup;
+import org.onap.optf.cmso.model.ChangeManagementSchedule;
+import org.onap.optf.cmso.model.Schedule;
+import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
+import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse;
+import org.onap.optf.cmso.optimizer.bean.CMSchedule;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Controller
+public class CMSOOptimizerCallbackImpl extends BaseSchedulerServiceImpl implements CMSOptimizerCallback {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(CMSOOptimizerCallbackImpl.class);
+ private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger();
+ private static EELFLogger audit = EELFManager.getInstance().getAuditLogger();
+ private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
+ private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
+
+ @Context
+ UriInfo uri;
+
+ @Context
+ HttpServletRequest request;
+
+
+ @Autowired
+ ChangeManagementScheduleDAO cmScheduleDAO;
+
+ @Autowired
+ ChangeManagementGroupDAO cmGroupDAO;
+
+ @Autowired
+ ChangeManagementChangeWindowDAO cmChangeWindowDAO;
+
+ @Autowired
+ ChangeManagementDetailDAO cmDetailsDAO;
+
+ @Override
+ @Transactional
+ public Response sniroCallback(String apiVersion, CMOptimizerResponse sniroResponse) {
+ Response response = null;
+ log.info(LogMessages.PROCESS_OPTIMIZER_CALLBACK, "Received", request.getRemoteAddr(), "");
+ log.info(LogMessages.OPTIMIZER_REQUEST, "Callback received", sniroResponse.getTransactionId(),
+ uri.getAbsolutePath().toString());
+ try {
+ // Note that transaction ID and schedule ID are currently the same value.
+
+ String transactionId = sniroResponse.getTransactionId();
+
+ // Synchronize this with transaction that scheduled the SNIRO optimization
+ // to ensure status updates are properly ordered.
+ // This is necessary only in the race condition where SNIRO callback comes
+ // before the SNIRO response is processed and the scheduling transaction is
+ // still in flight.
+ // Note that this may happen in loopback mode, but is not likely to happen with
+ // real SNIRO unless SNIRO changes to be synchronous and the callback comes before
+ // the response.
+ // If this lock times out, the schedule will remain in 'Optimization In
+ // Progress' and never complete.
+ Schedule schedule = scheduleDAO.lockOneByTransactionId(transactionId);
+
+ if (schedule == null) {
+ throw new CMSNotFoundException(DomainsEnum.ChangeManagement.toString(),
+ "(OptimizerTransactionID=" + transactionId + ")");
+
+ }
+ CMSStatusEnum status = CMSStatusEnum.PendingApproval.fromString(schedule.getStatus());
+ debug.debug("Status at time of SNIRO callback is " + status.toString());
+ switch (status) {
+ // PendingSchedule may be a valid status in the cases where SNIRO async call
+ // returns before
+ // We have committed the OptimizationInProgress status
+ // The dispatch logic ensures that we only every dispatch once.
+ case OptimizationInProgress:
+ processSniroResponse(sniroResponse, schedule);
+ scheduleDAO.save(schedule);
+ response = Response.ok().build();
+ break;
+ default:
+ throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR,
+ CMSStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString());
+ }
+ } catch (CMSException e) {
+ errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ response = Response.serverError().entity(e.getMessage()).build();
+ } finally {
+ }
+ return response;
+ }
+
+ private void processSniroResponse(CMOptimizerResponse sniroResponse, Schedule schedule) {
+ try {
+ schedule.setOptimizerReturnDateTimeMillis(System.currentTimeMillis());
+ schedule.setOptimizerStatus(sniroResponse.getRequestState());
+ schedule.setOptimizerMessage(sniroResponse.getDescription());
+ String scheduleId = sniroResponse.getScheduleId();
+ ObjectMapper om = new ObjectMapper();
+ CMSchedule[] scheduleArray = sniroResponse.getSchedule();
+ if (scheduleArray != null && scheduleArray.length > 0) {
+ String scheduleString = om.writeValueAsString(scheduleArray);
+ schedule.setSchedule(scheduleString);
+ log.debug("scheduleId={0} schedule={1}", scheduleId, scheduleString);
+ for (CMSchedule sniroSchedule : sniroResponse.getSchedule()) {
+ String groupId = sniroSchedule.getGroupId();
+ DateTime finishTime = convertDate(sniroSchedule.getFinishTime(), "finishTime");
+ DateTime latestInstanceStartTime =
+ convertDate(sniroSchedule.getLatestInstanceStartTime(), "latestInstanceStartTime");
+ DateTime startTime = convertDate(sniroSchedule.getStartTime(), "startTime");
+ ChangeManagementGroup group = cmGroupDAO.findOneBySchedulesIDGroupID(schedule.getUuid(), groupId);
+ if (group == null) {
+ throw new CMSException(Status.PRECONDITION_FAILED,
+ LogMessages.CHANGE_MANAGEMENT_GROUP_NOT_FOUND, schedule.getScheduleId(), groupId);
+ }
+ group.setStartTimeMillis(startTime.getMillis());
+ group.setFinishTimeMillis(finishTime.getMillis());
+ group.setLastInstanceStartTimeMillis(latestInstanceStartTime.getMillis());
+ cmGroupDAO.save(group);
+ long totalDuration =
+ (group.getAdditionalDurationInSecs() + group.getNormalDurationInSecs()) * 1000l;
+ Map<String, Map<String, Long>> startAndFinishTimeMap = new HashMap<String, Map<String, Long>>();
+ makeMap(startTime.getMillis(), latestInstanceStartTime.getMillis(), group.getConcurrencyLimit(),
+ totalDuration, sniroSchedule.getNode(), startAndFinishTimeMap);
+ for (String node : sniroSchedule.getNode()) {
+ processNode(schedule, group, node, startAndFinishTimeMap);
+ }
+ }
+ schedule.setStatus(CMSStatusEnum.PendingApproval.toString());
+ } else {
+ debug.debug("scheduleId={0} schedule=null status={1} ", scheduleId, schedule.getOptimizerStatus());
+ schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
+ }
+ } catch (CMSException e) {
+ errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
+ schedule.setOptimizerStatus(e.getStatus().toString());
+ schedule.setOptimizerMessage(e.getLocalizedMessage());
+ } catch (Exception e) {
+ errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
+ schedule.setOptimizerStatus("Exception");
+ schedule.setOptimizerMessage(e.getLocalizedMessage());
+ }
+ }
+
+ public static void makeMap(Long startTime, Long latestInstanceStartTime, int concurrencyLimit, long totalDuration,
+ List<String> nodes, Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException {
+ Long nextStartTime = null;
+ Long nextFinishTime = null;
+ for (int nodeNumber = 0; nodeNumber < nodes.size(); nodeNumber++) {
+ String node = nodes.get(nodeNumber);
+ if (nodeNumber % concurrencyLimit == 0) {
+ if (nodeNumber == 0)
+ nextStartTime = startTime;
+ else
+ nextStartTime = nextStartTime + totalDuration;
+ if (nextStartTime > latestInstanceStartTime) {
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS,
+ startTime.toString(), latestInstanceStartTime.toString(), String.valueOf(totalDuration),
+ String.valueOf(concurrencyLimit), String.valueOf(nodes.size()));
+ }
+ nextFinishTime = nextStartTime + totalDuration;
+ }
+ Map<String, Long> map = new HashMap<String, Long>();
+ map.put("startTime", nextStartTime);
+ map.put("finishTime", nextFinishTime);
+ startAndFinishTimeMap.put(node, map);
+ }
+
+ }
+
+ private void processNode(Schedule schedule, ChangeManagementGroup group, String node,
+ Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException {
+ Map<String, Long> map = startAndFinishTimeMap.get(node);
+ ChangeManagementSchedule detail = cmScheduleDAO.findOneByGroupIDAndVnfName(group.getUuid(), node);
+ if (detail == null) {
+ throw new CMSException(Status.NOT_FOUND, LogMessages.UNABLE_TO_LOCATE_SCHEDULE_DETAIL,
+ schedule.getScheduleId(), group.getGroupId(), node);
+ }
+ detail.setStartTimeMillis(map.get("startTime"));
+ detail.setFinishTimeMillis(map.get("finishTime"));
+ detail.setVnfId("");
+ detail.setStatus(CMSStatusEnum.PendingApproval.toString());
+ cmScheduleDAO.save(detail);
+ }
+
+ public static DateTime convertDate(String utcDate, String attrName) throws CMSException {
+ try {
+ DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC().parseDateTime(utcDate);
+ if (dateTime != null)
+ return dateTime;
+ } catch (Exception e) {
+ debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ }
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate);
+ }
+
+ public static DateTime convertISODate(String utcDate, String attrName) throws CMSException {
+ try {
+ DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate);
+ if (dateTime != null)
+ return dateTime;
+ } catch (Exception e) {
+ debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ }
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate);
+ }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java
index 97bb78e..6e99b0d 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-@Api
+@Api("CMSO Schedule API")
@Path("/{apiVersion}")
@Produces({MediaType.APPLICATION_JSON})
public interface CMSOService {
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java
index c3d61da..cc304db 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java
@@ -39,6 +39,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
+import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MultivaluedMap;
@@ -143,15 +144,15 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
}
Iterator<ScheduleQuery> iter = list.iterator();
while (iter.hasNext()) {
- Schedule s = scheduleDAO.findById(iter.next().getId()).orElse(null);
+ Schedule s = scheduleDAO.findById(iter.next().getUuid()).orElse(null);
if (s != null) {
schedules.add(s);
if (includeDetails) {
- List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(s.getId());
+ List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(s.getUuid());
s.setGroups(groups);
for (ChangeManagementGroup g : groups) {
List<ChangeManagementSchedule> cmSchedules =
- cmScheduleDAO.findByChangeManagementGroupId(g.getId());
+ cmScheduleDAO.findByChangeManagementGroupId(g.getUuid());
g.setChangeManagementSchedules(cmSchedules);
}
}
@@ -261,8 +262,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
if (cw.getEndTime() == null || cw.getEndTime().equals(""))
throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE,
"endTime");
- DateTime start = CMSCallbackImpl.convertISODate(cw.getStartTime(), "startTime");
- DateTime end = CMSCallbackImpl.convertISODate(cw.getEndTime(), "endTime");
+ DateTime start = CMSOOptimizerCallbackImpl.convertISODate(cw.getStartTime(), "startTime");
+ DateTime end = CMSOOptimizerCallbackImpl.convertISODate(cw.getEndTime(), "endTime");
if (!end.isAfter(start))
throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_CHANGE_WINDOW,
cw.getStartTime(), cw.getEndTime());
@@ -300,7 +301,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
CMSInfo schedulingInfo = scheduleMessage.getSchedulingInfo();
for (VnfDetailsMessage vnfDetail : schedulingInfo.getVnfDetails()) {
ChangeManagementGroup cmg = new ChangeManagementGroup();
- cmg.setSchedulesId(schedule.getId());
+ cmg.setUuid(UUID.randomUUID());
+ cmg.setSchedulesUuid(schedule.getUuid());
cmg.setGroupId("");
if (vnfDetail.getGroupId() != null)
cmg.setGroupId(vnfDetail.getGroupId());
@@ -311,9 +313,10 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
cmGroupDAO.save(cmg);
for (ChangeWindowMessage cw : vnfDetail.getChangeWindow()) {
ChangeManagementChangeWindow cmcw = new ChangeManagementChangeWindow();
- cmcw.setChangeManagementGroupsId(cmg.getId());
- DateTime start = CMSCallbackImpl.convertISODate(cw.getStartTime(), "startTime");
- DateTime end = CMSCallbackImpl.convertISODate(cw.getEndTime(), "startTime");
+ cmcw.setUuid(UUID.randomUUID());
+ cmcw.setChangeManagementGroupUuid(cmg.getUuid());
+ DateTime start = CMSOOptimizerCallbackImpl.convertISODate(cw.getStartTime(), "startTime");
+ DateTime end = CMSOOptimizerCallbackImpl.convertISODate(cw.getEndTime(), "startTime");
cmcw.setStartTimeMillis(start.getMillis());
cmcw.setFinishTimeMillis(end.getMillis());
cmChangeWindowDAO.save(cmcw);
@@ -321,7 +324,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
for (String vnf : vnfDetail.getNode()) {
ChangeManagementSchedule cms = new ChangeManagementSchedule();
- cms.setChangeManagementGroupsId(cmg.getId());
+ cms.setUuid(UUID.randomUUID());
+ cms.setChangeManagementGroupUuid(cmg.getUuid());
cms.setVnfName(vnf);
cms.setStatus(CMSStatusEnum.PendingSchedule.toString());
cmScheduleDAO.save(cms);
@@ -333,7 +337,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
CMSInfo schedulingInfo = scheduleMessage.getSchedulingInfo();
for (VnfDetailsMessage vnfDetail : schedulingInfo.getVnfDetails()) {
ChangeManagementGroup cmg = new ChangeManagementGroup();
- cmg.setSchedulesId(schedule.getId());
+ cmg.setUuid(UUID.randomUUID());
+ cmg.setSchedulesUuid(schedule.getUuid());
cmg.setGroupId("");
int duration = schedulingInfo.getNormalDurationInSeconds();
int backout = schedulingInfo.getAdditionalDurationInSeconds();
@@ -346,20 +351,22 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
cmGroupDAO.save(cmg);
for (String vnf : vnfDetail.getNode()) {
ChangeManagementSchedule cms = new ChangeManagementSchedule();
- cms.setChangeManagementGroupsId(cmg.getId());
+ cms.setUuid(UUID.randomUUID());
+ cms.setChangeManagementGroupUuid(cmg.getUuid());
cms.setVnfName(vnf);
cms.setStatus(CMSStatusEnum.PendingApproval.toString());
cmScheduleDAO.save(cms);
}
schedule.setStatus(CMSStatusEnum.PendingApproval.toString());
+ scheduleDAO.save(schedule);
}
}
private void deleteChangeManagement(Schedule schedule) throws CMSException {
- List<ChangeManagementGroup> cmgs = cmGroupDAO.findBySchedulesID(schedule.getId());
+ List<ChangeManagementGroup> cmgs = cmGroupDAO.findBySchedulesID(schedule.getUuid());
for (ChangeManagementGroup cmg : cmgs) {
- List<ChangeManagementSchedule> schedules = cmScheduleDAO.findByChangeManagementGroupId(cmg.getId());
+ List<ChangeManagementSchedule> schedules = cmScheduleDAO.findByChangeManagementGroupId(cmg.getUuid());
for (ChangeManagementSchedule s : schedules) {
CMSStatusEnum currentState = CMSStatusEnum.Completed.fromString(s.getStatus());
switch (currentState) {
@@ -494,7 +501,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
private void processApproveScheduleRequest(Schedule s, ApprovalMessage approval, List<DomainData> domainData)
throws CMSException {
- s = scheduleDAO.lockOne(s.getId());
+ s = scheduleDAO.lockOne(s.getUuid());
String domain = DomainsEnum.ChangeManagement.toString();
processApproval(s, domain, approval);
if (s.getStatus().equals(CMSStatusEnum.Accepted.toString())) {
@@ -510,10 +517,10 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
Integer max_vnfs_per_ticket = env.getProperty("tm.vnfs.per.ticket", Integer.class, 1);
- List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(s.getId());
+ List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(s.getUuid());
for (ChangeManagementGroup group : groups) {
- List<ChangeManagementSchedule> schedules = cmScheduleDAO.findByChangeManagementGroupId(group.getId());
+ List<ChangeManagementSchedule> schedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid());
List<List<ChangeManagementSchedule>> ticketList = new ArrayList<List<ChangeManagementSchedule>>();
List<ChangeManagementSchedule> current = null;
for (ChangeManagementSchedule cms : schedules) {
@@ -560,9 +567,9 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
private void updateChangeManagementSchedules(Schedule s, CMSStatusEnum approvalrejected) {
debug.debug("Entered updateChangeManagementSchedules");
- List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(s.getId());
+ List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(s.getUuid());
for (ChangeManagementGroup group : groups) {
- List<ChangeManagementSchedule> schedules = cmScheduleDAO.findByChangeManagementGroupId(group.getId());
+ List<ChangeManagementSchedule> schedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid());
for (ChangeManagementSchedule schedule : schedules) {
schedule.setStatus(approvalrejected.toString());
cmScheduleDAO.save(schedule);
@@ -603,7 +610,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
DomainsEnum.ChangeManagement.toString(), scheduleId);
}
Iterator<ChangeManagementDetail> iter = list.iterator();
- Map<Integer, Schedule> scheduleMap = new HashMap<Integer, Schedule>();
+ Map<UUID, Schedule> scheduleMap = new HashMap<UUID, Schedule>();
while (iter.hasNext()) {
ChangeManagementDetail cms = iter.next();
CmDetailsMessage msg = buildResponse(cms, scheduleMap);
@@ -636,7 +643,7 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
}
- private CmDetailsMessage buildResponse(ChangeManagementDetail cms, Map<Integer, Schedule> scheduleMap) {
+ private CmDetailsMessage buildResponse(ChangeManagementDetail cms, Map<UUID, Schedule> scheduleMap) {
CmDetailsMessage msg = new CmDetailsMessage();
msg.setVnfId(cms.getVnfId());
msg.setVnfName(cms.getVnfName());
@@ -656,17 +663,17 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
msg.setMsoRequestId(cms.getMsoRequestId());
msg.setMsoStatus(cms.getMsoStatus());
msg.setMsoTimeMillis(cms.getMsoTimeMillis());
- if (!scheduleMap.containsKey(cms.getSchedulesId())) {
- Schedule schedule = scheduleDAO.findById(cms.getSchedulesId()).orElse(null);
+ if (!scheduleMap.containsKey(cms.getSchedulesUuid())) {
+ Schedule schedule = scheduleDAO.findById(cms.getSchedulesUuid()).orElse(null);
if (schedule != null) {
// DO not innclude in the results
schedule.setScheduleInfo(null);
// schedule.setSchedule(null);
- scheduleMap.put(cms.getSchedulesId(), schedule);
+ scheduleMap.put(cms.getSchedulesUuid(), schedule);
}
}
- if (scheduleMap.containsKey(cms.getSchedulesId())) {
- msg.setScheduleRequest(scheduleMap.get(cms.getSchedulesId()));
+ if (scheduleMap.containsKey(cms.getSchedulesUuid())) {
+ msg.setScheduleRequest(scheduleMap.get(cms.getSchedulesUuid()));
}
return msg;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOptimizerCallback.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOptimizerCallback.java
index 99b4970..cc2785e 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOptimizerCallback.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOptimizerCallback.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,24 +31,23 @@
package org.onap.optf.cmso.service.rs;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
+
import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-@Api
+@Api("CMSO Optimized Schedule API")
@Path("/{apiVersion}")
@Produces({MediaType.APPLICATION_JSON})
public interface CMSOptimizerCallback {
@@ -62,7 +61,6 @@ public interface CMSOptimizerCallback {
@ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})
public Response sniroCallback(
@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
- @ApiParam(value = "Return schedules > lastScheduleId") CMOptimizerResponse reponse, @Context UriInfo uri,
- @Context HttpServletRequest request);
+ @ApiParam(value = "Return schedules > lastScheduleId") CMOptimizerResponse reponse);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java
index 1a9c29d..9877d33 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,188 +43,180 @@ import org.onap.optf.cmso.model.DomainData;
public class CmQueryParameters {
- public enum QueryColumns {
- RequestScheduleId("request.scheduleId", String.class, "ss.schedule_id"), RequestScheduleName(
- "request.scheduleName", String.class,
- "ss.schedule_name"), RequestUserId("request.userId", String.class, "ss.user_id"), RequestStatus(
- "request.status", String.class, "ss.status"), RequestCreateDateTime("request.createDateTime",
- Date.class, "ss.create_date_time"), RequestOptimizerStatus("request.optimizerStatus",
- String.class, "ss.optimizer_status"), RequestApprovalUserId(
- "request.approvalUserId", String.class,
- "sa.user_id"), RequestApprovalStatus("request.approvalStatus",
- String.class, "sa.status"), RequestApprovalType(
- "request.approvalType", String.class,
- "at.approval_type"), WorkflowName("WorkflowName",
- DomainData.class,
- "dd.value"), vnfName("vnfName", String.class,
- "s.vnf_name"), vnfId("vnfId",
- String.class,
- "s.vnf_id"), vnfStatus(
- "vnfStatus",
- String.class,
- "s.vnf_status"),
- // vnfScheduleId("vnfScheduleId", String.class, "s.id"),
- startTime("startTime", Date.class, "s.start_time"), finishTime("finishTime", Date.class,
- "s.finish_ime"), lastInstanceTime("lastInstanceTime", Date.class, "g.last_instance_time"), tmChangeId(
- "tmChangeId", String.class, "s.tm_change_id"), concurrenyLimit("request.concurrencyLimit",
- Integer.class, "g.concurrency_limit"),
- // approvalUserId("approvalUserId", String.class, "approvalUserId"),
- // approvalStatus("approvalStatus", String.class, "approvalStatus"),
- // approvalType("approvalType", String.class, "approvalType"),
- ;
+ public enum QueryColumns {
+ RequestScheduleId("request.scheduleId", String.class, "ss.schedule_id"),
+ RequestScheduleName("request.scheduleName", String.class, "ss.schedule_name"),
+ RequestUserId("request.userId", String.class, "ss.user_id"),
+ RequestStatus("request.status", String.class, "ss.status"),
+ RequestCreateDateTime("request.createDateTime", Date.class, "ss.create_date_time"),
+ RequestOptimizerStatus("request.optimizerStatus", String.class, "ss.optimizer_status"),
+ RequestApprovalUserId("request.approvalUserId", String.class, "sa.user_id"),
+ RequestApprovalStatus("request.approvalStatus", String.class, "sa.status"),
+ RequestApprovalType("request.approvalType", String.class, "at.approval_type"),
+ WorkflowName("WorkflowName", DomainData.class, "dd.value"), vnfName("vnfName", String.class, "s.vnf_name"),
+ vnfId("vnfId", String.class, "s.vnf_id"), vnfStatus("vnfStatus", String.class, "s.vnf_status"),
+ // vnfScheduleId("vnfScheduleId", String.class, "s.id"),
+ startTime("startTime", Date.class, "s.start_time"), finishTime("finishTime", Date.class, "s.finish_ime"),
+ lastInstanceTime("lastInstanceTime", Date.class, "g.last_instance_time"),
+ tmChangeId("tmChangeId", String.class, "s.tm_change_id"),
+ concurrenyLimit("request.concurrencyLimit", Integer.class, "g.concurrency_limit"),
+ // approvalUserId("approvalUserId", String.class, "approvalUserId"),
+ // approvalStatus("approvalStatus", String.class, "approvalStatus"),
+ // approvalType("approvalType", String.class, "approvalType"),
+ ;
- private final String urlName;
- private final Class<?> type;
- private final String col;
+ private final String urlName;
+ private final Class<?> type;
+ private final String col;
- private QueryColumns(String urlName, Class<?> type, String col) {
- this.urlName = urlName;
- this.type = type;
- this.col = col;
- }
+ private QueryColumns(String urlName, Class<?> type, String col) {
+ this.urlName = urlName;
+ this.type = type;
+ this.col = col;
+ }
- }
+ }
- public static QueryColumns getQueryColumn(String urlName) {
- for (QueryColumns qc : QueryColumns.values()) {
- if (qc.urlName.equals(urlName))
- return qc;
- }
- return null;
- }
+ public static QueryColumns getQueryColumn(String urlName) {
+ for (QueryColumns qc : QueryColumns.values()) {
+ if (qc.urlName.equals(urlName))
+ return qc;
+ }
+ return null;
+ }
- public static String buildClause(String urlName, List<String> values) throws CMSException {
- QueryColumns qc = getQueryColumn(urlName);
- if (qc == null) {
- throw new CMSException(Status.BAD_REQUEST, LogMessages.UNDEFINED_FILTER_ATTRIBUTE, urlName);
- }
- if (qc.type == Date.class) {
- return formatDate(urlName, values, qc);
- }
- if (qc.type == DomainData.class) {
- return formatDomainData(urlName, values, qc);
- }
- return formatString(urlName, values, qc);
- }
+ public static String buildClause(String urlName, List<String> values) throws CMSException {
+ QueryColumns qc = getQueryColumn(urlName);
+ if (qc == null) {
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.UNDEFINED_FILTER_ATTRIBUTE, urlName);
+ }
+ if (qc.type == Date.class) {
+ return formatDate(urlName, values, qc);
+ }
+ if (qc.type == DomainData.class) {
+ return formatDomainData(urlName, values, qc);
+ }
+ return formatString(urlName, values, qc);
+ }
- private static String formatString(String urlName, List<String> values, QueryColumns qc) {
- StringBuilder clause = new StringBuilder();
- List<String> likes = new ArrayList<String>();
- List<String> in = new ArrayList<String>();
- for (String value : values) {
- if (value.contains("%"))
- likes.add(value);
- else
- in.add(value);
- }
- String delim = "(";
- if (in.size() > 0) {
- clause.append(delim).append(qc.col).append(" in ('");
- String inDelim = "";
- for (String value : in) {
- clause.append(inDelim).append(value).append("'");
- inDelim = ", '";
- }
- clause.append(") ");
- delim = " OR ";
- }
- if (likes.size() > 0) {
- for (String value : likes) {
- clause.append(delim).append(qc.col).append(" like '").append(value).append("'");
- delim = " OR ";
- }
- }
- if (!delim.equals("("))
- clause.append(")");
- return clause.toString();
- }
+ private static String formatString(String urlName, List<String> values, QueryColumns qc) {
+ StringBuilder clause = new StringBuilder();
+ List<String> likes = new ArrayList<String>();
+ List<String> in = new ArrayList<String>();
+ for (String value : values) {
+ if (value.contains("%"))
+ likes.add(value);
+ else
+ in.add(value);
+ }
+ String delim = "(";
+ if (in.size() > 0) {
+ clause.append(delim).append(qc.col).append(" in ('");
+ String inDelim = "";
+ for (String value : in) {
+ clause.append(inDelim).append(value).append("'");
+ inDelim = ", '";
+ }
+ clause.append(") ");
+ delim = " OR ";
+ }
+ if (likes.size() > 0) {
+ for (String value : likes) {
+ clause.append(delim).append(qc.col).append(" like '").append(value).append("'");
+ delim = " OR ";
+ }
+ }
+ if (!delim.equals("("))
+ clause.append(")");
+ return clause.toString();
+ }
- private static String formatDomainData(String urlName, List<String> values, QueryColumns qc) {
- StringBuilder clause = new StringBuilder();
- String delim = "(";
- if (values.size() > 0) {
- for (String value : values) {
- clause.append(delim).append(" (dd.name = '").append(qc.urlName).append("' AND dd.value = '")
- .append(value).append("')");
- delim = " OR ";
- }
- }
- if (!delim.equals("("))
- clause.append(")");
- return clause.toString();
- }
+ private static String formatDomainData(String urlName, List<String> values, QueryColumns qc) {
+ StringBuilder clause = new StringBuilder();
+ String delim = "(";
+ if (values.size() > 0) {
+ for (String value : values) {
+ clause.append(delim).append(" (dd.name = '").append(qc.urlName).append("' AND dd.value = '")
+ .append(value).append("')");
+ delim = " OR ";
+ }
+ }
+ if (!delim.equals("("))
+ clause.append(")");
+ return clause.toString();
+ }
- private static String formatDate(String urlName, List<String> values, QueryColumns qc) throws CMSException {
- List<String> clauses = new ArrayList<String>();
- for (String value : values) {
- String dates[] = value.split(",");
- switch (dates.length) {
- case 2:
- formatDatePair(qc, dates[0].trim(), dates[1].trim(), clauses);
- break;
- case 1:
- formatDatePair(qc, dates[0].trim(), "", clauses);
- break;
- default:
- throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, value);
- }
- }
- StringBuilder clause = new StringBuilder();
- String delim = "(";
- for (String c : clauses) {
- clause.append(delim).append(c);
- delim = " OR ";
- }
- if (!delim.equals(")")) {
- clause.append(")");
- }
- return clause.toString();
- }
+ private static String formatDate(String urlName, List<String> values, QueryColumns qc) throws CMSException {
+ List<String> clauses = new ArrayList<String>();
+ for (String value : values) {
+ String dates[] = value.split(",");
+ switch (dates.length) {
+ case 2:
+ formatDatePair(qc, dates[0].trim(), dates[1].trim(), clauses);
+ break;
+ case 1:
+ formatDatePair(qc, dates[0].trim(), "", clauses);
+ break;
+ default:
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, value);
+ }
+ }
+ StringBuilder clause = new StringBuilder();
+ String delim = "(";
+ for (String c : clauses) {
+ clause.append(delim).append(c);
+ delim = " OR ";
+ }
+ if (!delim.equals(")")) {
+ clause.append(")");
+ }
+ return clause.toString();
+ }
- private static void formatDatePair(QueryColumns qc, String lowDate, String highDate, List<String> clauses)
- throws CMSException {
- StringBuilder clause = new StringBuilder();
- DateTime date1 = null;
- DateTime date2 = null;
- if (!lowDate.equals(""))
- date1 = convertDate(lowDate, qc.urlName);
- if (!highDate.equals(""))
- date2 = convertDate(highDate, qc.urlName);
- String delim = "(";
- if (date1 != null) {
- clause.append(delim).append(qc.col).append(" >= ").append(date1.getMillis());
- delim = " AND ";
- }
- if (date2 != null) {
- clause.append(delim).append(qc.col).append(" <= ").append(date2.getMillis());
- delim = " AND ";
- }
- if (!delim.equals(")")) {
- clause.append(")\n");
- clauses.add(clause.toString());
- }
- }
+ private static void formatDatePair(QueryColumns qc, String lowDate, String highDate, List<String> clauses)
+ throws CMSException {
+ StringBuilder clause = new StringBuilder();
+ DateTime date1 = null;
+ DateTime date2 = null;
+ if (!lowDate.equals(""))
+ date1 = convertDate(lowDate, qc.urlName);
+ if (!highDate.equals(""))
+ date2 = convertDate(highDate, qc.urlName);
+ String delim = "(";
+ if (date1 != null) {
+ clause.append(delim).append(qc.col).append(" >= ").append(date1.getMillis());
+ delim = " AND ";
+ }
+ if (date2 != null) {
+ clause.append(delim).append(qc.col).append(" <= ").append(date2.getMillis());
+ delim = " AND ";
+ }
+ if (!delim.equals(")")) {
+ clause.append(")\n");
+ clauses.add(clause.toString());
+ }
+ }
- private static DateTime convertDate(String utcDate, String urlName) throws CMSException {
- DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate);
- if (dateTime != null)
- return dateTime;
- throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, utcDate);
- }
+ private static DateTime convertDate(String utcDate, String urlName) throws CMSException {
+ DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate);
+ if (dateTime != null)
+ return dateTime;
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, utcDate);
+ }
- // public static void main(String argv[])
- // {
- // List<String> values = new ArrayList<String>();
- // values.add("2017-07-08T11:12:13Z,2017-07-08T11:12:13Z");
- // values.add("2017-07-09T11:12:13Z,2017-07-09T11:12:13Z");
- // values.add(",2017-07-09T11:12:13Z");
- // values.add(" 2017-07-09T11:12:13Z");
- // try {
- // System.out.println(buildClause("request.createDateTime", values));
- // } catch (SchedulerException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- //
- // }
+ // public static void main(String argv[])
+ // {
+ // List<String> values = new ArrayList<String>();
+ // values.add("2017-07-08T11:12:13Z,2017-07-08T11:12:13Z");
+ // values.add("2017-07-09T11:12:13Z,2017-07-09T11:12:13Z");
+ // values.add(",2017-07-09T11:12:13Z");
+ // values.add(" 2017-07-09T11:12:13Z");
+ // try {
+ // System.out.println(buildClause("request.createDateTime", values));
+ // } catch (SchedulerException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ //
+ // }
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java
index edc2c96..fb69e31 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,25 +31,24 @@
package org.onap.optf.cmso.service.rs;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
+
import org.onap.optf.cmso.service.rs.models.HealthCheckMessage;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-@Api
+@Api("CMSO Administration")
@Path("/{apiVersion}")
@Produces({MediaType.APPLICATION_JSON})
public interface HealthCheck {
@@ -63,7 +62,7 @@ public interface HealthCheck {
@ApiResponse(code = 400, message = "Not healthy", response = HealthCheckMessage.class)})
public Response healthCheck(@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
@DefaultValue(value = "true") @ApiParam(value = "Check Interfaces",
- allowMultiple = true) @QueryParam("checkInterfaces") Boolean checkInterfaces,
- @Context UriInfo uri, @Context HttpServletRequest request);
+ allowMultiple = true) @QueryParam("checkInterfaces") Boolean checkInterfaces
+ );
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java
index 0877a6b..8e6b09e 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java
@@ -34,6 +34,7 @@ package org.onap.optf.cmso.service.rs;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -55,11 +56,17 @@ import com.att.eelf.configuration.EELFManager;
public class HealthCheckImpl implements HealthCheck {
private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
+ @Context
+ UriInfo uri;
+
+ @Context
+ HttpServletRequest request;
+
@Autowired
TmClient tmClient;
@Autowired
- CMSOptimizerClient sniroClient;
+ CMSOptimizerClient optimizerClient;
@Autowired
ApprovalTypeDAO approvalTypeDAO;
@@ -71,7 +78,7 @@ public class HealthCheckImpl implements HealthCheck {
MsoStatusClient msoStatusClient;
@Override
- public Response healthCheck(String apiVersion, Boolean checkInterfaces, UriInfo uri, HttpServletRequest request) {
+ public Response healthCheck(String apiVersion, Boolean checkInterfaces) {
debug.debug("Entered healthcheck");
Response response = null;
HealthCheckMessage hc = new HealthCheckMessage();
@@ -80,7 +87,7 @@ public class HealthCheckImpl implements HealthCheck {
if (checkInterfaces) {
addToHealthCheckMessage(hc, tmClient.healthCheck());
addToHealthCheckMessage(hc, msoStatusClient.healthCheck());
- addToHealthCheckMessage(hc, sniroClient.healthCheck());
+ addToHealthCheckMessage(hc, optimizerClient.healthCheck());
}
addToHealthCheckMessage(hc, this.healthCheck());
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/ChangeWindow.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/ChangeWindow.java
new file mode 100644
index 0000000..7553c87
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/ChangeWindow.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.
+*/
+
+package org.onap.optf.cmso.service.rs.models.v2;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import org.springframework.format.annotation.DateTimeFormat;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "Change Window",
+ description = "Time window for which tickets are to returned")
+public class ChangeWindow implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ChangeWindow.class);
+
+ @ApiModelProperty(value = "Earliest time for which changes may begin.")
+ @DateTimeFormat(pattern="yyyy-MM-dd'T'hh:mm:ss'Z'")
+ private Date startTime;
+
+ @ApiModelProperty(value = "Latest time by which all changes must be completed.")
+ @DateTimeFormat(pattern="yyyy-MM-dd'T'hh:mm:ss'Z'")
+ private Date endTime;
+
+ public Date getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(Date startTime) {
+ this.startTime = startTime;
+ }
+
+ public Date getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(Date endTime) {
+ this.endTime = endTime;
+ }
+
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/ElementInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/ElementInfo.java
new file mode 100644
index 0000000..35649ea
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/ElementInfo.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ *
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.
+ ******************************************************************************/
+package org.onap.optf.cmso.service.rs.models.v2;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "Optimizer Element", description = "Element to be scheduled.")
+public class ElementInfo implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ElementInfo.class);
+
+ @ApiModelProperty(value = "Element identifier")
+ private String elementId;
+
+ @ApiModelProperty(value = "Implementation specific element data.")
+ public List<NameValue> elementData = new ArrayList<>();
+
+ @ApiModelProperty(value = "Request for be scheduled.")
+ public Object request;
+
+ public String getElementId() {
+ return elementId;
+ }
+
+ public void setElementId(String elementId) {
+ this.elementId = elementId;
+ }
+
+
+ public List<NameValue> getElementData() {
+ return elementData;
+ }
+
+ public void setElementData(List<NameValue> elementData) {
+ this.elementData = elementData;
+ }
+
+ public Object getRequest() {
+ return request;
+ }
+
+ public void setRequest(Object request) {
+ this.request = request;
+ }
+
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/NameValue.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/NameValue.java
new file mode 100644
index 0000000..9b71f76
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/NameValue.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2017-2019 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.
+*/
+
+package org.onap.optf.cmso.service.rs.models.v2;
+
+import java.io.Serializable;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "Name Value Data",
+ description = "Instance of a name/value")
+public class NameValue implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(NameValue.class);
+
+ public NameValue()
+ {
+
+ }
+
+ public NameValue(String name, Object value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+
+ @ApiModelProperty(value = "Name.")
+ private String name;
+
+ @ApiModelProperty(value = "Value.")
+ private Object value;
+
+
+ public String getName() {
+ return name;
+ }
+
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ public Object getValue() {
+ return value;
+ }
+
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/OptimizedScheduleMessage.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/OptimizedScheduleMessage.java
new file mode 100644
index 0000000..797379c
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/OptimizedScheduleMessage.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.
+*/
+
+package org.onap.optf.cmso.service.rs.models.v2;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * The persistent class for the approval_types database table.
+ *
+ */
+@ApiModel(value = "Optimized Schedule Request", description = "Request to schedule VNF change management workflow(s).")
+public abstract class OptimizedScheduleMessage implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizedScheduleMessage.class);
+
+ // public abstract void setSchedulingInfo(Object schedulingInfo);
+
+ @ApiModelProperty(value = "Schedule domain : ChangeManagement")
+ private String domain;
+
+ @ApiModelProperty(value = "Schedule id that must be unique within the domain. Use of UUID is highly recommended.")
+ private String scheduleId;
+
+ @ApiModelProperty(value = "User provided name of the schedule (deaults to scheduleId")
+ private String scheduleName;
+
+ @ApiModelProperty(value = "ATTUID of the user requesting the schedule.")
+ private String userId;
+
+ @ApiModelProperty(value = "Implementation specific name value pairs.")
+ private List<NameValue> commonData;
+
+ @ApiModelProperty(value = "Scheduling data.")
+ private SchedulingData schedulingData;
+
+ public String getDomain() {
+ return domain;
+ }
+
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+
+ public String getScheduleId() {
+ return scheduleId;
+ }
+
+ public void setScheduleId(String scheduleId) {
+ this.scheduleId = scheduleId;
+ }
+
+ public String getScheduleName() {
+ return scheduleName;
+ }
+
+ public void setScheduleName(String scheduleName) {
+ this.scheduleName = scheduleName;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public List<NameValue> getCommonData() {
+ return commonData;
+ }
+
+ public void setCommonData(List<NameValue> commonData) {
+ this.commonData = commonData;
+ }
+
+ public SchedulingData getSchedulingData() {
+ return schedulingData;
+ }
+
+ public void setSchedulingData(SchedulingData schedulingData) {
+ this.schedulingData = schedulingData;
+ }
+
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/PolicyInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/PolicyInfo.java
new file mode 100644
index 0000000..c6a291c
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/PolicyInfo.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ *
+ * Copyright © 2019 AT&T Intellectual Property.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.
+ ******************************************************************************/
+package org.onap.optf.cmso.service.rs.models.v2;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "Supported Policy Information", description = "Policy Information returned from get policies API.")
+public class PolicyInfo implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(PolicyInfo.class);
+
+ @ApiModelProperty(value = "Policy name")
+ private String policyName;
+
+ @ApiModelProperty(value = "Named values to modify/override policy attributes.")
+ public List<NameValue> policyModifiers = new ArrayList<>();
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+
+ public List<NameValue> getPolicyModifiers() {
+ return policyModifiers;
+ }
+
+ public void setPolicyModifiers(List<NameValue> policyModifiers) {
+ this.policyModifiers = policyModifiers;
+ }
+
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/SchedulingData.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/SchedulingData.java
new file mode 100644
index 0000000..e17f1d2
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/SchedulingData.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.
+*/
+
+package org.onap.optf.cmso.service.rs.models.v2;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * The persistent class for the approval_types database table.
+ *
+ */
+@ApiModel(value = "Change Management Scheduling Info", description = "Details of schedule being requested")
+public class SchedulingData implements Serializable {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(SchedulingData.class);
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "Expected duration (in seconds) of a successful execution of a single VNF change.")
+ private Integer normalDurationInSeconds;
+
+ @ApiModelProperty(value = "Additional duration (in seconds) to be added to support backout of an unsuccessful VNF change.")
+ private Integer additionalDurationInSeconds;
+
+ @ApiModelProperty(value = "Maximum number of VNF changes to schedule concurrently")
+ private Integer concurrencyLimit;
+
+ @ApiModelProperty(value = "Lists of desired change windows to schedule the elements.")
+ private List<ChangeWindow> changeWindows = new ArrayList<>();
+
+ @ApiModelProperty(value = "List of the policies to control optimization.")
+ private List<PolicyInfo> policies = new ArrayList<>();
+
+ @ApiModelProperty(value = "Lists of the VNFs to be changed and the desired change windows")
+ private List<ElementInfo> elements;
+
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+
+ public Integer getNormalDurationInSeconds() {
+ return normalDurationInSeconds;
+ }
+
+ public void setNormalDurationInSeconds(Integer normalDurationInSeconds) {
+ this.normalDurationInSeconds = normalDurationInSeconds;
+ }
+
+ public Integer getAdditionalDurationInSeconds() {
+ return additionalDurationInSeconds;
+ }
+
+ public void setAdditionalDurationInSeconds(Integer additionalDurationInSeconds) {
+ this.additionalDurationInSeconds = additionalDurationInSeconds;
+ }
+
+ public Integer getConcurrencyLimit() {
+ return concurrencyLimit;
+ }
+
+ public void setConcurrencyLimit(Integer concurrencyLimit) {
+ this.concurrencyLimit = concurrencyLimit;
+ }
+
+ public List<ChangeWindow> getChangeWindows() {
+ return changeWindows;
+ }
+
+ public void setChangeWindows(List<ChangeWindow> changeWindows) {
+ this.changeWindows = changeWindows;
+ }
+
+ public List<PolicyInfo> getPolicies() {
+ return policies;
+ }
+
+ public void setPolicies(List<PolicyInfo> policies) {
+ this.policies = policies;
+ }
+
+ public List<ElementInfo> getElements() {
+ return elements;
+ }
+
+ public void setElements(List<ElementInfo> elements) {
+ this.elements = elements;
+ }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java
index 7a7821e..41534f8 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java
@@ -34,6 +34,7 @@ package org.onap.optf.cmso.sostatus;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
+import java.util.UUID;
import javax.ws.rs.ProcessingException;
import javax.ws.rs.client.Client;
@@ -87,10 +88,11 @@ public class MsoStatusClient {
@Autowired
PropertiesManagement pm;
- public void execute(Integer id) throws JobExecutionException {
+ public void execute(String id) throws JobExecutionException {
debug.debug(LogMessages.MSO_STATUS_JOB, "Entered", id.toString());
try {
- ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(id);
+ UUID uuid = UUID.fromString(id);
+ ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(uuid);
if (cmSchedule == null) {
Observation.report(LogMessages.MSO_POLLING_MISSING_SCHEDULE, id.toString());
return;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java
index df9f361..6c52cc3 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java
@@ -31,6 +31,8 @@
package org.onap.optf.cmso.sostatus;
+import java.util.UUID;
+
import org.onap.observations.Mdc;
import org.onap.optf.cmso.common.LogMessages;
import org.onap.optf.cmso.model.ChangeManagementSchedule;
@@ -73,20 +75,21 @@ public class MsoStatusJob implements Job {
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
Mdc.quartzJobBegin(context);
- Integer id = context.getJobDetail().getJobDataMap().getInt(ContextKeys.scheduleId.toString());
+ String id = context.getJobDetail().getJobDataMap().getString(ContextKeys.scheduleId.toString());
String requestId = context.getJobDetail().getJobDataMap().getString(ContextKeys.msoRequestId.toString());
debug.debug(LogMessages.MSO_STATUS_JOB, "Entered", requestId, id.toString());
try {
- ChangeManagementSchedule cmSchedule = cmScheduleDAO.findById(id).orElse(null);
+ UUID uuid = UUID.fromString(id);
+ ChangeManagementSchedule cmSchedule = cmScheduleDAO.findById(uuid).orElse(null);
if (cmSchedule == null) {
- log.warn(LogMessages.MSO_POLLING_MISSING_SCHEDULE, id.toString(), requestId);
+ log.warn(LogMessages.MSO_POLLING_MISSING_SCHEDULE, id, requestId);
return;
}
mso.poll(cmSchedule);
} catch (Exception e) {
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
}
- debug.debug(LogMessages.MSO_STATUS_JOB, "Exited", requestId, id.toString());
+ debug.debug(LogMessages.MSO_STATUS_JOB, "Exited", requestId, id);
}
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java
index c3254aa..1c3677c 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java
@@ -33,6 +33,7 @@ package org.onap.optf.cmso.sostatus;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -93,8 +94,8 @@ public class ScheduleStatusJob implements Job {
// First poll SO for WF status
List<ChangeManagementSchedule> list = cmScheduleDAO.findAllTriggered();
for (ChangeManagementSchedule s : list) {
- debug.debug("Dispathcing to check status of CM schedule Id=" + s.getId());
- dispatchMso(s.getId());
+ debug.debug("Dispathcing to check status of CM schedule Id=" + s.getUuid());
+ dispatchMso(s.getUuid());
}
} catch (Exception e) {
Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
@@ -106,7 +107,7 @@ public class ScheduleStatusJob implements Job {
List<Schedule> list = scheduleDAO.findAllInProgress(DomainsEnum.ChangeManagement.toString());
for (Schedule s : list) {
debug.debug("Dispatching to check status of scheduleId=" + s.getScheduleId());
- dispatchScheduleStatusChecker(s.getId());
+ dispatchScheduleStatusChecker(s.getUuid());
}
} catch (Exception e) {
Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
@@ -114,12 +115,12 @@ public class ScheduleStatusJob implements Job {
debug.debug(LogMessages.SCHEDULE_STATUS_JOB, "Exited");
}
- public void dispatchScheduleStatusChecker(Integer id) {
+ public void dispatchScheduleStatusChecker(UUID uuid) {
Map<String, String> mdcSave = Mdc.save();
try {
String url = env.getProperty("cmso.dispatch.url", "http://localhost:8089");
String path = env.getProperty("cmso.dispatch.status.path", "/cmso/dispatch/schedulestatus/");
- url = url + path + id;
+ url = url + path + uuid;
String user = env.getProperty("mechid.user", "");
String pass = pm.getProperty("mechid.pass", "");
Client client = ClientBuilder.newClient();
@@ -152,12 +153,12 @@ public class ScheduleStatusJob implements Job {
}
- public void dispatchMso(Integer id) {
+ public void dispatchMso(UUID uuid) {
Map<String, String> mdcSave = Mdc.save();
try {
String url = env.getProperty("cmso.dispatch.url", "http://localhost:8089");
String path = env.getProperty("cmso.dispatch.sostatus.path", "/cmso/dispatch/sostatus/");
- url = url + path + id;
+ url = url + path + uuid;
String user = env.getProperty("mechid.user", "");
String pass = pm.getProperty("mechid.pass", "");
Client client = ClientBuilder.newClient();
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java
index b240b61..b2ff6d4 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@ import org.onap.optf.cmso.optimizer.bean.CMRequestInfo;
import org.onap.optf.cmso.optimizer.bean.CMSchedule;
import org.onap.optf.cmso.optimizer.bean.CMSchedulingInfo;
import org.onap.optf.cmso.optimizer.bean.CMVnfDetails;
-import org.onap.optf.cmso.service.rs.CMSCallbackImpl;
+import org.onap.optf.cmso.service.rs.CMSOOptimizerCallbackImpl;
import org.onap.optf.cmso.wf.bean.WfCmResponse200;
import org.onap.optf.cmso.wf.bean.WfMsoRequestReferences;
import org.onap.optf.cmso.wf.bean.WfMsoResponse;
@@ -101,11 +101,11 @@ public class SchedulerTestLoopbackServiceImpl implements SchedulerTestLoopbackSe
nodes.add(sr.getNode());
}
- DateTime startTime = CMSCallbackImpl.convertISODate(si.getStartTime(), "startTime");
+ DateTime startTime = CMSOOptimizerCallbackImpl.convertISODate(si.getStartTime(), "startTime");
// Ignore the finish time for now in the calc. Just accept what they
// gave
- DateTime finishTime = CMSCallbackImpl.convertISODate(si.getEndTime(), "endTime");
+ DateTime finishTime = CMSOOptimizerCallbackImpl.convertISODate(si.getEndTime(), "endTime");
DateTimeFormatter sniroFmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC();
int add = si.getAdditionalDurationInSecs();
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java
index e5c14b1..e327acc 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,6 +37,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.UUID;
+
import javax.transaction.Transactional;
import org.onap.optf.cmso.common.CMSStatusEnum;
import org.onap.optf.cmso.common.LogMessages;
@@ -97,11 +99,12 @@ public class TmStatusClient {
TmClient tmClient;
@Transactional
- public void checkStatus(Integer id) {
+ public void checkStatus(String id) {
debug.debug("Entered checkStatus id=" + id);
try {
// Multiple cmso instance support - re-get the record with a Schedule lock
- Schedule s = scheduleDAO.lockOne(id);
+ UUID uuid = UUID.fromString(id);
+ Schedule s = scheduleDAO.lockOne(uuid);
if (!s.getStatus().equals(CMSStatusEnum.NotificationsInitiated.toString())) {
debug.debug(s.getScheduleId() + " is no longer in " + CMSStatusEnum.NotificationsInitiated.toString()
+ " : it is " + s.getStatus());
@@ -110,7 +113,7 @@ public class TmStatusClient {
}
Map<GroupAuditStatus, List<ChangeManagementGroup>> groupStatus =
new HashMap<GroupAuditStatus, List<ChangeManagementGroup>>();
- List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(id);
+ List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(uuid);
// Close tickets for completed VNFs
for (ChangeManagementGroup group : groups) {
@@ -155,7 +158,7 @@ public class TmStatusClient {
Map<String, List<ChangeManagementSchedule>> inProgress = new HashMap<String, List<ChangeManagementSchedule>>();
Map<String, List<ChangeManagementSchedule>> completed = new HashMap<String, List<ChangeManagementSchedule>>();
Map<String, List<ChangeManagementSchedule>> tmClosed = new HashMap<String, List<ChangeManagementSchedule>>();
- List<ChangeManagementSchedule> cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getId());
+ List<ChangeManagementSchedule> cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid());
for (ChangeManagementSchedule cmSchedule : cmSchedules) {
String status = cmSchedule.getStatus();
String changeId = cmSchedule.getTmChangeId();
@@ -230,7 +233,7 @@ public class TmStatusClient {
Set<String> failedNames = new HashSet<String>();
Set<String> completedNames = new HashSet<String>();
Long startDate = group.getStartTimeMillis();
- List<ChangeManagementSchedule> cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getId());
+ List<ChangeManagementSchedule> cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid());
for (ChangeManagementSchedule cmSchedule : cmSchedules) {
String vnfName = cmSchedule.getVnfName();
vnfNames.add(vnfName);
diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java
index f16c94c..caf7e8b 100644
--- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java
+++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java
@@ -52,6 +52,8 @@ public enum LogMessages implements ObservationInterface {
UPDATE_TICKET("Update ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
GET_ACTIVE_TICKETS("Get active tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
SEARCH_TICKETS("Search tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
+ DELETE_ACTIVE_TICKETS("Delete active tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
+ POLL_ACTIVE_TICKETS("Polling active tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO),
TICKET_NOT_FOUND("Ticket not found id={0}", Status.NOT_FOUND, Level.INFO),
INVALID_ATTRIBUTE("Invalid attribute {0}={1}", Status.BAD_REQUEST, Level.INFO),
@@ -73,7 +75,7 @@ public enum LogMessages implements ObservationInterface {
EXPECTED_EXCEPTION("Expected exception encountered during processing. {0}", Status.OK, Level.INFO),
UNABLE_TO_UPDATE_TICKET("Unable to update change ticket in TM: Schedule ID: {0} : changeid: {1} : Reason: {2}", Status.OK, Level.INFO),
UNAUTHORIZED("Authorization failed.", Status.FORBIDDEN, Level.INFO),
- UNAUTHENTICATED("Authentication failed.", Status.UNAUTHORIZED, Level.INFO),
+ UNAUTHENTICATED("Authentication failed.", Status.UNAUTHORIZED, Level.INFO),
;
private final String defaultId;
diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java
index b4b3626..60fccd1 100644
--- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java
+++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java
@@ -31,7 +31,9 @@
package org.onap.optf.ticketmgt.service.rs;
+import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -63,8 +65,10 @@ public interface AvailabilityInterface {
@Produces({MediaType.APPLICATION_JSON})
@RequestMapping(value = "/{apiVersion}/activetickets", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON)
- @ApiOperation(value = "", notes = "API to support conflict avoidance. Retrieves the active ticket data for the "
- + "passed criteria to detemine availability of passed elements within the passed time window",
+ @ApiOperation(value = "Request Active Tickets", notes = "API to support conflict avoidance. Retrieves the active ticket data for the "
+ + "passed criteria to detemine availability of passed elements within the passed time window."
+ + "\nIf the request results in asynchronous processging, IN_PROGRESS status will be returned and the "
+ + "optimizer will begin to poll the request until COMPLETED.",
response = ActiveTicketsResponse.class)
@ApiResponses(
value = {@ApiResponse(code = 200, message = "OK"),
@@ -75,6 +79,41 @@ public interface AvailabilityInterface {
@ApiParam(value = "Active ticket criteria (elements and change windows).") ActiveTicketsRequest activeTicketsRequest
);
+ @GET
+ @Path("/activetickets/{id}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @RequestMapping(value = "/{apiVersion}/activetickets/{id}", method = RequestMethod.GET,
+ consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Poll Active Tickets Request", notes = "Poll for the status of the request id. Optimizser will "
+ + " poll until status is COMPLETED and issue acknowledge (DELETE) API to acknowledge the "
+ + "receipt of the response.",
+ response = ActiveTicketsResponse.class)
+ @ApiResponses(
+ value = {@ApiResponse(code = 200, message = "OK"),
+ @ApiResponse(code = 404, message = "Not found.", response = CMSRequestError.class),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})
+ public Response pollActiveTickets(
+ @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable(value="v1") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Active tickets request id.") @PathParam("id") String id
+ );
+
+ @DELETE
+ @Path("/activetickets/{id}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @RequestMapping(value = "/{apiVersion}/activetickets/{id}", method = RequestMethod.DELETE,
+ consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Acknowledge Active Tickets Response", notes = "API call used to acknowledge the receipt"
+ + " of a COMPLETED asynchronous request to enable the Ticket Management service to remove it from their cache."
+ + " The service may remove from the cache on the poll request. The optimizer will treat Not found reponse on as normal.",
+ response = ActiveTicketsResponse.class)
+ @ApiResponses(
+ value = {@ApiResponse(code = 204, message = "OK"),
+ @ApiResponse(code = 404, message = "Not found", response = CMSRequestError.class),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})
+ public Response deleteActiveTicketsRequest(
+ @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable(value="v1") @DefaultValue("v1") String apiVersion,
+ @ApiParam(value = "Active tickets request id.") @PathParam("id") String id
+ );
}
diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterfaceImpl.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterfaceImpl.java
index 1120983..9538f46 100644
--- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterfaceImpl.java
+++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterfaceImpl.java
@@ -40,6 +40,7 @@ import org.onap.observations.Observation;
import org.onap.optf.ticketmgt.common.LogMessages;
import org.onap.optf.ticketmgt.service.rs.models.ActiveTicketsRequest;
import org.onap.optf.ticketmgt.service.rs.models.ActiveTicketsResponse;
+import org.onap.optf.ticketmgt.service.rs.models.ActiveTicketsResponse.ActiveTicketResponseStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
@@ -73,6 +74,7 @@ public class AvailabilityInterfaceImpl implements AvailabilityInterface {
{
ActiveTicketsResponse atr = new ActiveTicketsResponse();
atr.setRequestId(activeTicketsRequest.getRequestId());
+ atr.setStatus(ActiveTicketResponseStatus.COMPLETED);
response = Response.ok(atr).build();
// } catch (CMSException e) {
// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -86,4 +88,51 @@ public class AvailabilityInterfaceImpl implements AvailabilityInterface {
Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString());
return response;
}
+
+
+ @Override
+ public Response pollActiveTickets(String apiVersion, String id) {
+ // TODO Auto-generated method stub
+ Observation.report(LogMessages.POLL_ACTIVE_TICKETS, "Received", request.getRemoteAddr(), id, "");
+ Response response = null;
+ try
+ {
+ ActiveTicketsResponse atr = new ActiveTicketsResponse();
+ atr.setRequestId(id);
+ atr.setStatus(ActiveTicketResponseStatus.COMPLETED);
+ response = Response.ok(atr).build();
+// } catch (CMSException e) {
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
+// response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ response = Response.serverError().build();
+ }
+ Observation.report(LogMessages.POLL_ACTIVE_TICKETS, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString());
+ return response;
+ }
+
+
+ @Override
+ public Response deleteActiveTicketsRequest(String apiVersion, String id) {
+ // TODO Auto-generated method stub
+ Observation.report(LogMessages.DELETE_ACTIVE_TICKETS, "Received", request.getRemoteAddr(), id, "");
+ Response response = null;
+ try
+ {
+ response = Response.noContent().build();
+// } catch (CMSException e) {
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
+// response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ response = Response.serverError().build();
+ }
+ Observation.report(LogMessages.DELETE_ACTIVE_TICKETS, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString());
+ return response;
+ }
}
diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java
index 1931296..13e7f6d 100644
--- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java
+++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java
@@ -31,7 +31,6 @@
package org.onap.optf.ticketmgt.service.rs;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
@@ -41,10 +40,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
import org.onap.optf.cmso.common.CMSRequestError;
import org.onap.optf.ticketmgt.service.rs.models.TicketData;
diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsResponse.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsResponse.java
index d26fc6f..d3d5f7d 100644
--- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsResponse.java
+++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsResponse.java
@@ -48,12 +48,23 @@ public class ActiveTicketsResponse implements Serializable {
private static final long serialVersionUID = 1L;
private static EELFLogger log = EELFManager.getInstance().getLogger(ActiveTicketsResponse.class);
+ public enum ActiveTicketResponseStatus
+ {
+ IN_PROGESS,
+ COMPLETED,
+ }
@ApiModelProperty(value = "Unique Id of the request")
private String requestId;
@ApiModelProperty(value = "List of TicketData for the requested elements. A single ticket may apply to more than 1 passed elementId.")
private List<TicketData> elements = new ArrayList<>();
+ @ApiModelProperty(value = "Status of ticket request. IN_PROGRESS will indicate asynchronous processing is required.")
+ private ActiveTicketResponseStatus status;
+
+ @ApiModelProperty(value = "If request is asynchronous (IN_PROGRESS), suggested interval to the next poll.")
+ private Integer pollingSeconds;
+
public String getRequestId() {
return requestId;
}
@@ -70,6 +81,22 @@ public class ActiveTicketsResponse implements Serializable {
this.elements = elements;
}
+ public ActiveTicketResponseStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(ActiveTicketResponseStatus status) {
+ this.status = status;
+ }
+
+ public Integer getPollingSeconds() {
+ return pollingSeconds;
+ }
+
+ public void setPollingSeconds(Integer pollingSeconds) {
+ this.pollingSeconds = pollingSeconds;
+ }
+
public String toString() {
ObjectMapper mapper = new ObjectMapper();
try {
diff --git a/cmso-ticketmgt/src/main/resources/logmessages.properties b/cmso-ticketmgt/src/main/resources/logmessages.properties
index de09032..045d6ee 100644
--- a/cmso-ticketmgt/src/main/resources/logmessages.properties
+++ b/cmso-ticketmgt/src/main/resources/logmessages.properties
@@ -5,6 +5,8 @@ CANCEL_TICKET CANCEL_TICKET|Cancel ticket {0} : {1}: {2} : {3}|No resolution nee
UPDATE_TICKET UPDATE_TICKET|Update ticket {0} : {1}: {2} : {3}|No resolution needed|No action is required
GET_ACTIVE_TICKETS GET_ACTIVE_TICKETS|Get active tickets {0} : {1}: {2} : {3}|No resolution needed|No action is required
SEARCH_TICKETS SEARCH_TICKETS|Search tickets {0} : {1}: {2} : {3}|No resolution needed|No action is required
+DELETE_ACTIVE_TICKETS DELETE_ACTIVE_TICKETS|Delete active tickets {0} : {1}: {2} : {3}|No resolution needed|No action is required
+POLL_ACTIVE_TICKETS POLL_ACTIVE_TICKETS|Polling active tickets {0} : {1}: {2} : {3}|No resolution needed|No action is required
TICKET_NOT_FOUND TICKET_NOT_FOUND|Ticket not found id={0}|No resolution needed|No action is required
INVALID_ATTRIBUTE INVALID_ATTRIBUTE|Invalid attribute {0}={1}|No resolution needed|No action is required
MISSING_REQUIRED_ATTRIBUTE MISSING_REQUIRED_ATTRIBUTE|Missing required attribute '{0}'|No resolution needed|No action is required
diff --git a/pom.xml b/pom.xml
index 51bdd6d..e8e6f14 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,6 @@
<modules>
<module>cmso-service</module>
<module>cmso-database</module>
- <module>cmso-robot</module>
</modules>
<build>