Commit 16 for Create Optimized Sched API 41/83241/1
authorJerry Flood <jflood@att.com>
Mon, 25 Mar 2019 16:28:14 +0000 (12:28 -0400)
committerJerry Flood <jflood@att.com>
Mon, 25 Mar 2019 17:12:42 +0000 (13:12 -0400)
Multiple commits required due to commit size limitation.

Change-Id: I7b766a7ec8036460964e8dbe85d96f049515ecd8
Issue-ID: OPTFRA-458
Signed-off-by: Jerry Flood <jflood@att.com>
cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java
cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java
cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java
cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackService.java
cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java
cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/TicketMgtLoopbackService.java

index 41534f8..e760b85 100644 (file)
@@ -1,41 +1,39 @@
 /*\r
- * Copyright © 2017-2019 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
+ * Copyright © 2017-2019 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ *\r
+ *\r
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative\r
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * https://creativecommons.org/licenses/by/4.0/\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, documentation distributed under the\r
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\r
+ * express or implied. See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
+ */\r
 \r
 package org.onap.optf.cmso.sostatus;\r
 \r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+import com.fasterxml.jackson.databind.node.ObjectNode;\r
 import java.text.SimpleDateFormat;\r
 import java.util.Date;\r
 import java.util.Map;\r
 import java.util.UUID;\r
-\r
 import javax.ws.rs.ProcessingException;\r
 import javax.ws.rs.client.Client;\r
 import javax.ws.rs.client.ClientBuilder;\r
@@ -43,44 +41,38 @@ import javax.ws.rs.client.Invocation;
 import javax.ws.rs.client.WebTarget;\r
 import javax.ws.rs.core.MediaType;\r
 import javax.ws.rs.core.Response;\r
-\r
 import org.onap.observations.Mdc;\r
 import org.onap.observations.Observation;\r
 import org.onap.optf.cmso.common.BasicAuthenticatorFilter;\r
 import org.onap.optf.cmso.common.CMSStatusEnum;\r
 import org.onap.optf.cmso.common.LogMessages;\r
 import org.onap.optf.cmso.common.PropertiesManagement;\r
-import org.onap.optf.cmso.filters.CMSOClientFilters;\r
+import org.onap.optf.cmso.filters.CmsoClientFilters;\r
 import org.onap.optf.cmso.model.ChangeManagementSchedule;\r
 import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;\r
 import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;\r
 import org.onap.optf.cmso.model.dao.ScheduleDAO;\r
 import org.onap.optf.cmso.service.rs.models.HealthCheckComponent;\r
 import org.onap.optf.cmso.so.bean.MsoOrchestrationQueryResponse;\r
-import org.onap.optf.cmso.so.bean.MsoOrchestrationQueryResponse.MSO_STATUS;\r
+import org.onap.optf.cmso.so.bean.MsoOrchestrationQueryResponse.MsoStatus;\r
 import org.quartz.JobExecutionException;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.core.env.Environment;\r
 import org.springframework.stereotype.Component;\r
 import org.springframework.transaction.annotation.Transactional;\r
 \r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-\r
 @Component\r
 public class MsoStatusClient {\r
     private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();\r
 \r
     @Autowired\r
-    ChangeManagementScheduleDAO cmScheduleDAO;\r
+    ChangeManagementScheduleDAO cmScheduleDao;\r
 \r
     @Autowired\r
-    ChangeManagementGroupDAO cmGroupDAO;\r
+    ChangeManagementGroupDAO cmGroupdao;\r
 \r
     @Autowired\r
-    ScheduleDAO scheduleDAO;\r
+    ScheduleDAO scheduleDao;\r
 \r
     @Autowired\r
     Environment env;\r
@@ -88,22 +80,33 @@ public class MsoStatusClient {
     @Autowired\r
     PropertiesManagement pm;\r
 \r
+    /**\r
+     * Execute.\r
+     *\r
+     * @param id the id\r
+     * @throws JobExecutionException the job execution exception\r
+     */\r
     public void execute(String id) throws JobExecutionException {\r
         debug.debug(LogMessages.MSO_STATUS_JOB, "Entered", id.toString());\r
         try {\r
-               UUID uuid = UUID.fromString(id);\r
-            ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(uuid);\r
+            UUID uuid = UUID.fromString(id);\r
+            ChangeManagementSchedule cmSchedule = cmScheduleDao.lockOne(uuid);\r
             if (cmSchedule == null) {\r
                 Observation.report(LogMessages.MSO_POLLING_MISSING_SCHEDULE, id.toString());\r
                 return;\r
             }\r
             poll(cmSchedule);\r
         } catch (Exception e) {\r
-               Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());\r
+            Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());\r
         }\r
         debug.debug(LogMessages.MSO_STATUS_JOB, "Exited", id.toString());\r
     }\r
 \r
+    /**\r
+     * Poll.\r
+     *\r
+     * @param cmSchedule the cm schedule\r
+     */\r
     @Transactional\r
     public void poll(ChangeManagementSchedule cmSchedule) {\r
         Map<String, String> mdcSave = Mdc.save();\r
@@ -113,12 +116,13 @@ public class MsoStatusClient {
             String url = env.getProperty("so.url");\r
             String user = env.getProperty("so.user");\r
             String pass = pm.getProperty("so.pass", "");\r
-            if (!url.endsWith("/"))\r
+            if (!url.endsWith("/")) {\r
                 url = url + "/";\r
+            }\r
             url = url + requestId;\r
             Client client = ClientBuilder.newClient();\r
             client.register(new BasicAuthenticatorFilter(user, pass));\r
-            client.register(new CMSOClientFilters());\r
+            client.register(new CmsoClientFilters());\r
             WebTarget target = client.target(url);\r
             Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON);\r
             Response response = null;\r
@@ -132,11 +136,11 @@ public class MsoStatusClient {
                     if (resp != null) {\r
                         cmSchedule.setMsoStatus(resp.getRequestState());\r
                         cmSchedule.setMsoMessage(resp.getStatusMessage());\r
-                        MSO_STATUS msoStatus = MSO_STATUS.UNKNOWN;\r
+                        MsoStatus msoStatus = MsoStatus.UNKNOWN;\r
                         try {\r
-                            msoStatus = MSO_STATUS.valueOf(resp.getRequestState());\r
+                            msoStatus = MsoStatus.valueOf(resp.getRequestState());\r
                         } catch (Exception e) {\r
-                               Observation.report(LogMessages.UNRECOGNIZED_MSO_STATUS, resp.getRequestState());\r
+                            Observation.report(LogMessages.UNRECOGNIZED_MSO_STATUS, resp.getRequestState());\r
                         }\r
                         long finishTime = getFinishTime(resp);\r
                         switch (msoStatus) {\r
@@ -161,16 +165,14 @@ public class MsoStatusClient {
 \r
                 }\r
                     break;\r
-                case 404: // Not found\r
-                {\r
+                case 404: { // Not found\r
                     // Do not keep polling...\r
                     cmSchedule.setStatus(CMSStatusEnum.Failed.toString());\r
                     cmSchedule.setMsoStatus("Not found");\r
                     cmSchedule.setMsoMessage("Call to MSO Failed :" + response.toString());\r
                 }\r
                     break;\r
-                case 400: // Bad request\r
-                {\r
+                case 400: { // Bad request\r
                     // Do not keep polling...\r
                     cmSchedule.setStatus(CMSStatusEnum.Error.toString());\r
                     cmSchedule.setMsoStatus("Bad Request");\r
@@ -191,7 +193,7 @@ public class MsoStatusClient {
             cmSchedule.setMsoStatus("ConnectionException");\r
             cmSchedule.setMsoMessage("Could not call MSO:" + e.getMessage());\r
         } catch (Exception e) {\r
-               Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());\r
+            Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());\r
             // Probably a transient error... Keep polling\r
             cmSchedule.setMsoTimeMillis(System.currentTimeMillis());\r
             cmSchedule.setMsoStatus("Exception");\r
@@ -200,7 +202,7 @@ public class MsoStatusClient {
             Mdc.restore(mdcSave);\r
         }\r
         // Propagate final MSO status to top level\r
-        cmScheduleDAO.save(cmSchedule);\r
+        cmScheduleDao.save(cmSchedule);\r
         propagateStatus(cmSchedule);\r
 \r
     }\r
@@ -214,7 +216,8 @@ public class MsoStatusClient {
                 Date dateTime = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z").parse(timestr);\r
                 finishTime = dateTime.getTime();\r
             } catch (Exception e) {\r
-               Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, "Unable to parse MSO finish timestamp: " + timestr);\r
+                Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e,\r
+                                "Unable to parse MSO finish timestamp: " + timestr);\r
             }\r
         }\r
         return finishTime;\r
@@ -232,22 +235,26 @@ public class MsoStatusClient {
             ObjectNode request = (ObjectNode) json.get("request");\r
             ObjectNode requestStatus = (ObjectNode) request.get("requestStatus");\r
             MsoOrchestrationQueryResponse msoResponse =\r
-                    om.treeToValue(requestStatus, MsoOrchestrationQueryResponse.class);\r
+                            om.treeToValue(requestStatus, MsoOrchestrationQueryResponse.class);\r
             return msoResponse;\r
         } catch (Exception e) {\r
-               Observation.report(LogMessages.UNABLE_TO_PARSE_MSO_RESPONSE, e, e.getMessage(), resp);\r
+            Observation.report(LogMessages.UNABLE_TO_PARSE_MSO_RESPONSE, e, e.getMessage(), resp);\r
         }\r
         return null;\r
     }\r
 \r
+    /**\r
+     * Health check.\r
+     *\r
+     * @return the health check component\r
+     */\r
     public HealthCheckComponent healthCheck() {\r
         Map<String, String> mdcSave = Mdc.save();\r
         String requestId = "healthCheck";\r
         String url = env.getProperty("so.url", "");\r
-        String user = env.getProperty("so.user", "");\r
-        String pass = pm.getProperty("so.pass", "");\r
-        if (!url.endsWith("/"))\r
+        if (!url.endsWith("/")) {\r
             url = url + "/";\r
+        }\r
         url = url + "healthcheck";\r
 \r
         HealthCheckComponent hcc = new HealthCheckComponent();\r
@@ -255,8 +262,11 @@ public class MsoStatusClient {
         hcc.setUrl(url);\r
 \r
         Client client = ClientBuilder.newClient();\r
+        String user = env.getProperty("so.user", "");\r
+        String pass = pm.getProperty("so.pass", "");\r
+\r
         client.register(new BasicAuthenticatorFilter(user, pass));\r
-        client.register(new CMSOClientFilters());\r
+        client.register(new CmsoClientFilters());\r
 \r
         WebTarget target = client.target(url);\r
         Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON);\r
index 6c52cc3..0a4c2f2 100644 (file)
@@ -1,38 +1,34 @@
 /*\r
- * Copyright © 2017-2019 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
+ * Copyright © 2017-2019 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ *\r
+ *\r
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative\r
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * https://creativecommons.org/licenses/by/4.0/\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, documentation distributed under the\r
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\r
+ * express or implied. See the License for the specific language governing permissions and\r
  * limitations under the License.\r
-*/\r
+ */\r
 \r
 package org.onap.optf.cmso.sostatus;\r
 \r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
 import java.util.UUID;\r
-\r
 import org.onap.observations.Mdc;\r
 import org.onap.optf.cmso.common.LogMessages;\r
 import org.onap.optf.cmso.model.ChangeManagementSchedule;\r
@@ -44,12 +40,10 @@ import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.core.env.Environment;\r
 import org.springframework.stereotype.Component;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
 \r
 /**\r
- * This is the Quartz Job that is run to send the workflow to VID for execution\r
- * \r
+ * This is the Quartz Job that is run to send the workflow to VID for execution.\r
+ *\r
  *\r
  */\r
 @Component\r
@@ -63,7 +57,7 @@ public class MsoStatusJob implements Job {
     MsoStatusClient mso;\r
 \r
     @Autowired\r
-    ChangeManagementScheduleDAO cmScheduleDAO;\r
+    ChangeManagementScheduleDAO cmScheduleDao;\r
 \r
     @Autowired\r
     Environment env;\r
@@ -79,8 +73,8 @@ public class MsoStatusJob implements Job {
         String requestId = context.getJobDetail().getJobDataMap().getString(ContextKeys.msoRequestId.toString());\r
         debug.debug(LogMessages.MSO_STATUS_JOB, "Entered", requestId, id.toString());\r
         try {\r
-               UUID uuid = UUID.fromString(id);\r
-            ChangeManagementSchedule cmSchedule = cmScheduleDAO.findById(uuid).orElse(null);\r
+            UUID uuid = UUID.fromString(id);\r
+            ChangeManagementSchedule cmSchedule = cmScheduleDao.findById(uuid).orElse(null);\r
             if (cmSchedule == null) {\r
                 log.warn(LogMessages.MSO_POLLING_MISSING_SCHEDULE, id, requestId);\r
                 return;\r
index 1c3677c..9eacfd1 100644 (file)
@@ -1,27 +1,27 @@
 /*\r
  * Copyright © 2017-2019 AT&T Intellectual Property.\r
  * Modifications Copyright © 2018 IBM.\r
- * \r
+ *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, software\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * \r
+ *\r
+ *\r
  * Unless otherwise specified, all documentation contained herein is licensed\r
  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
  * you may not use this documentation except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, documentation\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
 \r
 package org.onap.optf.cmso.sostatus;\r
 \r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
 import java.util.List;\r
 import java.util.Map;\r
 import java.util.UUID;\r
-\r
 import javax.ws.rs.client.Client;\r
 import javax.ws.rs.client.ClientBuilder;\r
 import javax.ws.rs.client.Invocation;\r
 import javax.ws.rs.client.WebTarget;\r
 import javax.ws.rs.core.MediaType;\r
 import javax.ws.rs.core.Response;\r
-\r
 import org.onap.observations.Mdc;\r
 import org.onap.observations.Observation;\r
 import org.onap.optf.cmso.common.BasicAuthenticatorFilter;\r
 import org.onap.optf.cmso.common.DomainsEnum;\r
 import org.onap.optf.cmso.common.LogMessages;\r
 import org.onap.optf.cmso.common.PropertiesManagement;\r
-import org.onap.optf.cmso.filters.CMSOClientFilters;\r
+import org.onap.optf.cmso.filters.CmsoClientFilters;\r
 import org.onap.optf.cmso.model.ChangeManagementSchedule;\r
 import org.onap.optf.cmso.model.Schedule;\r
 import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;\r
@@ -62,12 +62,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;\r
 import org.springframework.stereotype.Component;\r
 \r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-\r
 /**\r
- * This is the Quartz Job that is run to send the workflow to VID for execution\r
- * \r
+ * This is the Quartz Job that is run to send the workflow to VID for execution.\r
+ *\r
  *\r
  */\r
 @Component\r
@@ -76,10 +73,10 @@ public class ScheduleStatusJob implements Job {
     private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();\r
 \r
     @Autowired\r
-    ScheduleDAO scheduleDAO;\r
+    ScheduleDAO scheduleDao;\r
 \r
     @Autowired\r
-    ChangeManagementScheduleDAO cmScheduleDAO;\r
+    ChangeManagementScheduleDAO cmScheduleDao;\r
 \r
     @Autowired\r
     PropertiesManagement pm;\r
@@ -87,12 +84,18 @@ public class ScheduleStatusJob implements Job {
     @Autowired\r
     Environment env;\r
 \r
+    /**\r
+     * Execute.\r
+     *\r
+     * @param context the context\r
+     * @throws JobExecutionException the job execution exception\r
+     */\r
     @Override\r
     public void execute(JobExecutionContext context) throws JobExecutionException {\r
         debug.debug(LogMessages.SCHEDULE_STATUS_JOB, "Entered");\r
         try {\r
             // First poll SO for WF status\r
-            List<ChangeManagementSchedule> list = cmScheduleDAO.findAllTriggered();\r
+            List<ChangeManagementSchedule> list = cmScheduleDao.findAllTriggered();\r
             for (ChangeManagementSchedule s : list) {\r
                 debug.debug("Dispathcing to check status of CM schedule Id=" + s.getUuid());\r
                 dispatchMso(s.getUuid());\r
@@ -104,7 +107,7 @@ public class ScheduleStatusJob implements Job {
 \r
             //\r
             // Update overall status of in flight schedules including closing tickets\r
-            List<Schedule> list = scheduleDAO.findAllInProgress(DomainsEnum.ChangeManagement.toString());\r
+            List<Schedule> list = scheduleDao.findAllInProgress(DomainsEnum.ChangeManagement.toString());\r
             for (Schedule s : list) {\r
                 debug.debug("Dispatching to check status of scheduleId=" + s.getScheduleId());\r
                 dispatchScheduleStatusChecker(s.getUuid());\r
@@ -115,6 +118,11 @@ public class ScheduleStatusJob implements Job {
         debug.debug(LogMessages.SCHEDULE_STATUS_JOB, "Exited");\r
     }\r
 \r
+    /**\r
+     * Dispatch schedule status checker.\r
+     *\r
+     * @param uuid the uuid\r
+     */\r
     public void dispatchScheduleStatusChecker(UUID uuid) {\r
         Map<String, String> mdcSave = Mdc.save();\r
         try {\r
@@ -125,7 +133,7 @@ public class ScheduleStatusJob implements Job {
             String pass = pm.getProperty("mechid.pass", "");\r
             Client client = ClientBuilder.newClient();\r
             client.register(new BasicAuthenticatorFilter(user, pass));\r
-            client.register(CMSOClientFilters.class);\r
+            client.register(CmsoClientFilters.class);\r
             WebTarget target = client.target(url);\r
             Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON);\r
             Response response = null;\r
@@ -153,6 +161,11 @@ public class ScheduleStatusJob implements Job {
 \r
     }\r
 \r
+    /**\r
+     * Dispatch mso.\r
+     *\r
+     * @param uuid the uuid\r
+     */\r
     public void dispatchMso(UUID uuid) {\r
         Map<String, String> mdcSave = Mdc.save();\r
         try {\r
@@ -163,7 +176,7 @@ public class ScheduleStatusJob implements Job {
             String pass = pm.getProperty("mechid.pass", "");\r
             Client client = ClientBuilder.newClient();\r
             client.register(new BasicAuthenticatorFilter(user, pass));\r
-            client.register(CMSOClientFilters.class);\r
+            client.register(CmsoClientFilters.class);\r
             WebTarget target = client.target(url);\r
             Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON);\r
             Response response = null;\r
index f75365a..0200520 100644 (file)
@@ -1,36 +1,36 @@
 /*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ *\r
+ *\r
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative\r
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * https://creativecommons.org/licenses/by/4.0/\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, documentation distributed under the\r
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\r
+ * express or implied. See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
+ */\r
 \r
 package org.onap.optf.cmso.test.loopback;\r
 \r
+import io.swagger.annotations.Api;\r
+import io.swagger.annotations.ApiOperation;\r
+import io.swagger.annotations.ApiParam;\r
+import io.swagger.annotations.ApiResponse;\r
+import io.swagger.annotations.ApiResponses;\r
 import javax.ws.rs.GET;\r
 import javax.ws.rs.POST;\r
 import javax.ws.rs.Path;\r
@@ -40,14 +40,10 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;\r
 import javax.ws.rs.core.Response;\r
 import javax.ws.rs.core.UriInfo;\r
-import org.onap.optf.cmso.optimizer.bean.CMOptimizerRequest;\r
+import org.onap.optf.cmso.optimizer.model.OptimizerRequest;\r
+import org.onap.optf.cmso.optimizer.model.OptimizerResponse;\r
 import org.onap.optf.cmso.so.bean.MsoOrchestrationQueryResponse;\r
 import org.onap.optf.cmso.wf.bean.WfChangeManagementResponse;\r
-import io.swagger.annotations.Api;\r
-import io.swagger.annotations.ApiOperation;\r
-import io.swagger.annotations.ApiParam;\r
-import io.swagger.annotations.ApiResponse;\r
-import io.swagger.annotations.ApiResponses;\r
 \r
 @Api\r
 @Path("/v1/loopbacktest")\r
@@ -55,24 +51,34 @@ import io.swagger.annotations.ApiResponses;
 public interface SchedulerTestLoopbackService {\r
     // ******************************************************************\r
     @POST\r
-    @Path("/optimizer")\r
+    @Path("/optimize/schedule")\r
     @Produces({MediaType.APPLICATION_JSON})\r
     @ApiOperation(value = "", notes = "Test Optimizer connection in loopback mode.")\r
     @ApiResponses(value = {@ApiResponse(code = 202, message = "OK"),\r
-            @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
-    public Response putToOptimizer(@ApiParam(value = "SNIRO request message") CMOptimizerRequest request,\r
-            @Context UriInfo uri);\r
+                    @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
+    public Response putToOptimizer(@ApiParam(value = "Optimizer request message") OptimizerRequest request,\r
+                    @Context UriInfo uri);\r
+\r
+    // ******************************************************************\r
+    @GET\r
+    @Path("/optimize/schedule/{id}")\r
+    @Produces({MediaType.APPLICATION_JSON})\r
+    @ApiOperation(value = "", notes = "Test Optimizer connection in loopback mode.", response = OptimizerResponse.class)\r
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),\r
+                    @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
+    public Response getOptimizerResponse(@ApiParam(value = "Optimizer request is") @PathParam("id") String id,\r
+                    @Context UriInfo uri);\r
 \r
     // ******************************************************************\r
     @POST\r
     @Path("/onap/so/infra/orchestrationRequests/v7/schedule/{vnfName}")\r
     @Produces({MediaType.APPLICATION_JSON})\r
     @ApiOperation(value = "", notes = "Test SO sheduling in loopback mode.",\r
-            response = WfChangeManagementResponse.class)\r
+                    response = WfChangeManagementResponse.class)\r
     @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),\r
-            @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
+                    @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
     public Response soScheduleLoopback(@ApiParam(value = "vnfName") @PathParam("vnfName") String vnfName,\r
-            @ApiParam(value = "SO request message") String request, @Context UriInfo uri);\r
+                    @ApiParam(value = "SO request message") String request, @Context UriInfo uri);\r
 \r
     // ******************************************************************\r
     @GET\r
@@ -80,8 +86,8 @@ public interface SchedulerTestLoopbackService {
     @Produces({MediaType.APPLICATION_JSON})\r
     @ApiOperation(value = "", notes = "Test SO Status query loopback.", response = MsoOrchestrationQueryResponse.class)\r
     @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),\r
-            @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
+                    @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
     public Response soQueryLoopback(@ApiParam(value = "MSO request ID") @PathParam("requestId") String requestId,\r
-            @Context UriInfo uri);\r
+                    @Context UriInfo uri);\r
 \r
 }\r
index b2ff6d4..b179719 100644 (file)
@@ -1,79 +1,67 @@
 /*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ *\r
+ *\r
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative\r
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * https://creativecommons.org/licenses/by/4.0/\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, documentation distributed under the\r
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\r
+ * express or implied. See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *         https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
+ */\r
 \r
 package org.onap.optf.cmso.test.loopback;\r
 \r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
 import java.util.ArrayList;\r
+import java.util.Date;\r
 import java.util.HashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
 import java.util.UUID;\r
-import javax.ws.rs.ProcessingException;\r
-import javax.ws.rs.client.Client;\r
-import javax.ws.rs.client.ClientBuilder;\r
-import javax.ws.rs.client.Entity;\r
-import javax.ws.rs.client.Invocation;\r
-import javax.ws.rs.client.ResponseProcessingException;\r
-import javax.ws.rs.client.WebTarget;\r
-import javax.ws.rs.core.MediaType;\r
 import javax.ws.rs.core.Response;\r
 import javax.ws.rs.core.Response.Status;\r
 import javax.ws.rs.core.UriInfo;\r
 import org.joda.time.DateTime;\r
-import org.joda.time.format.DateTimeFormat;\r
-import org.joda.time.format.DateTimeFormatter;\r
-import org.onap.optf.cmso.common.BasicAuthenticatorFilter;\r
+import org.onap.observations.Observation;\r
 import org.onap.optf.cmso.common.LogMessages;\r
 import org.onap.optf.cmso.common.PropertiesManagement;\r
-import org.onap.optf.cmso.optimizer.bean.CMOptimizerRequest;\r
-import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse;\r
-import org.onap.optf.cmso.optimizer.bean.CMRequestInfo;\r
-import org.onap.optf.cmso.optimizer.bean.CMSchedule;\r
-import org.onap.optf.cmso.optimizer.bean.CMSchedulingInfo;\r
-import org.onap.optf.cmso.optimizer.bean.CMVnfDetails;\r
-import org.onap.optf.cmso.service.rs.CMSOOptimizerCallbackImpl;\r
+import org.onap.optf.cmso.optimizer.model.OptimizerRequest;\r
+import org.onap.optf.cmso.optimizer.model.OptimizerResponse;\r
+import org.onap.optf.cmso.optimizer.model.OptimizerScheduleInfo;\r
+import org.onap.optf.cmso.optimizer.model.ScheduledElement;\r
+import org.onap.optf.cmso.optimizer.model.ScheduledElement.ScheduleType;\r
+import org.onap.optf.cmso.optimizer.model.UnScheduledElement;\r
+import org.onap.optf.cmso.service.rs.CmsoOptimizerCallbackImpl;\r
+import org.onap.optf.cmso.service.rs.models.v2.ChangeWindow;\r
+import org.onap.optf.cmso.service.rs.models.v2.ElementInfo;\r
 import org.onap.optf.cmso.wf.bean.WfCmResponse200;\r
 import org.onap.optf.cmso.wf.bean.WfMsoRequestReferences;\r
 import org.onap.optf.cmso.wf.bean.WfMsoResponse;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.core.env.Environment;\r
 import org.springframework.stereotype.Controller;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
 \r
 @Controller\r
 public class SchedulerTestLoopbackServiceImpl implements SchedulerTestLoopbackService {\r
     private static EELFLogger log = EELFManager.getInstance().getLogger(SchedulerTestLoopbackServiceImpl.class);\r
     private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();\r
-    private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();\r
 \r
     @Autowired\r
     Environment env;\r
@@ -81,70 +69,22 @@ public class SchedulerTestLoopbackServiceImpl implements SchedulerTestLoopbackSe
     @Autowired\r
     PropertiesManagement pm;\r
 \r
+    // **\r
+    // This is test mode only code.\r
+    private static Map<String, String> optimizerResponses = new HashMap<>();\r
+\r
     @Override\r
-    public Response putToOptimizer(CMOptimizerRequest request, UriInfo uri) {\r
+    public Response putToOptimizer(OptimizerRequest request, UriInfo uri) {\r
         //\r
         try {\r
-            CMOptimizerResponse r = new CMOptimizerResponse();\r
-            CMRequestInfo ri = request.getRequestInfo();\r
-            CMSchedulingInfo si = request.getSchedulingInfo();\r
-            r.setTransactionId(ri.getTransactionId());\r
-            r.setRequestState("Done.");\r
-            r.setScheduleId(ri.getRequestId());\r
-            String callback = ri.getCallbackUrl();\r
-\r
-            // This is a dumb opt. WIll not make sense for multiple groups\r
-            // Use the code in the callback to help\r
-            List<String> nodes = new ArrayList<String>();\r
-            // get total number of nodes across all groups.\r
-            for (CMVnfDetails sr : si.getVnfDetails()) {\r
-                nodes.add(sr.getNode());\r
-            }\r
-\r
-            DateTime startTime = CMSOOptimizerCallbackImpl.convertISODate(si.getStartTime(), "startTime");\r
-\r
-            // Ignore the finish time for now in the calc. Just accept what they\r
-            // gave\r
-            DateTime finishTime = CMSOOptimizerCallbackImpl.convertISODate(si.getEndTime(), "endTime");\r
-            DateTimeFormatter sniroFmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC();\r
-\r
-            int add = si.getAdditionalDurationInSecs();\r
-            int normal = si.getNormalDurationInSecs();\r
-            int concurrencyLimit = si.getConcurrencyLimit();\r
-            long totalDuration = (long) add + normal;\r
-            long serialized = 0;\r
-            if (nodes.size() > concurrencyLimit) {\r
-                serialized = (nodes.size() / concurrencyLimit);\r
-                serialized = (serialized * totalDuration) * 1000;\r
-            }\r
-            DateTime latestInstanceStartTime = startTime.plus(serialized);\r
-            finishTime = latestInstanceStartTime.plus(totalDuration * 1000);\r
-            // Reformat request into a response setting the groups start finish\r
-            // time based upon\r
-            Map<String, CMSchedule> map = new HashMap<String, CMSchedule>();\r
-            for (CMVnfDetails sr : si.getVnfDetails()) {\r
-                String groupId = sr.getGroupId();\r
-                CMSchedule cms = map.get(groupId);\r
-                if (cms == null) {\r
-                    cms = new CMSchedule();\r
-                    cms.setGroupId(groupId);\r
-                    cms.setFinishTime(groupId);\r
-                    map.put(groupId, cms);\r
-                    cms.setStartTime(sniroFmt.print(startTime));\r
-                    cms.setFinishTime(sniroFmt.print(finishTime));\r
-                    cms.setLatestInstanceStartTime(sniroFmt.print(latestInstanceStartTime));\r
-                }\r
-                cms.getNode().add(sr.getNode());\r
-            }\r
-            r.setSchedule(map.values().toArray(new CMSchedule[map.values().size()]));\r
-\r
-            Thread responseThread = new Thread(new Runnable() {\r
-                public void run() {\r
-                    sendAsyncResponse(r, callback);\r
-                }\r
-            });\r
-            responseThread.start();\r
-\r
+            OptimizerResponse rsp = new OptimizerResponse();\r
+            rsp.setRequestId(request.getRequestId());\r
+            rsp.setStatus(OptimizerResponse.OptimizeScheduleStatus.COMPLETED);\r
+            List<OptimizerScheduleInfo> schedules = getSchedules(request);\r
+            rsp.setSchedules(schedules);\r
+            ObjectMapper om = new ObjectMapper();\r
+            String response = om.writeValueAsString(rsp);\r
+            optimizerResponses.put(rsp.getRequestId(), response);\r
             return Response.accepted().build();\r
         } catch (Exception e) {\r
             log.error("Unexpected exception", e);\r
@@ -152,45 +92,90 @@ public class SchedulerTestLoopbackServiceImpl implements SchedulerTestLoopbackSe
         return Response.serverError().build();\r
     }\r
 \r
-    private void sendAsyncResponse(CMOptimizerResponse r, String url) {\r
+    private List<OptimizerScheduleInfo> getSchedules(OptimizerRequest request) {\r
+        List<OptimizerScheduleInfo> list = new ArrayList<>();\r
+        OptimizerScheduleInfo osi = new OptimizerScheduleInfo();\r
+        List<ScheduledElement> scheduledList = new ArrayList<>();\r
+        List<UnScheduledElement> unscheduledList = new ArrayList<>();\r
+        osi.setScheduledElements(scheduledList);\r
+        osi.setUnScheduledElements(unscheduledList);\r
+        list.add(osi);\r
+\r
+\r
+        List<ChangeWindow> cws = request.getChangeWindows();\r
+        // Assume we cannot get here without at least 1 CW\r
+        ChangeWindow cw = cws.get(0);\r
+\r
+        // This is a dumb opt. WIll not make sense for multiple groups\r
+        // Use the code in the callback to help\r
+        Map<String, String> nodes = new HashMap<>();\r
+        List<String> nodeList = new ArrayList<>();\r
+        // get total number of nodes across all groups.\r
+        for (ElementInfo sr : request.getElements()) {\r
+            nodes.put(sr.getElementId(), sr.getGroupId());\r
+            nodeList.add(sr.getElementId());\r
+        }\r
+\r
+        DateTime startTime = new DateTime(cw.getStartTime().getTime());\r
+\r
+\r
+        long add = request.getAdditionalDuration() * 1000L;\r
+        long normal = request.getNormalDuration() * 1000L;\r
+        int concurrencyLimit = request.getConcurrencyLimit();\r
+        long totalDuration = add + normal;\r
+        long serialized = 0;\r
+        if (nodes.size() > concurrencyLimit) {\r
+            serialized = (nodes.size() / concurrencyLimit);\r
+            serialized = (serialized * totalDuration);\r
+        }\r
+        DateTime latestInstanceStartTime = startTime.plus(serialized);\r
+        DateTime finishTime = latestInstanceStartTime.plus(totalDuration);\r
+        // Reformat request into a response setting the groups start finish\r
+        // time based upon\r
+\r
+        Map<String, Map<String, Long>> startAndFinishTimeMap = new HashMap<String, Map<String, Long>>();\r
         try {\r
-            Client client = ClientBuilder.newClient();\r
-            String user = env.getProperty("mechid.user", "");\r
-            String pass = pm.getProperty("mechid.pass", "");\r
-            client.register(new BasicAuthenticatorFilter(user, pass));\r
-            WebTarget target = client.target(url);\r
-            Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON);\r
-            try {\r
-                Response response = invocationBuilder.post(Entity.json(r));\r
-                switch (response.getStatus()) {\r
-                    case 202:\r
-                        // Scheduled with SNIRO\r
-                        break;\r
-                    case 400: // Bad request\r
-                    case 500:\r
-                    default: {\r
-                    }\r
-                }\r
-            } catch (ResponseProcessingException e) {\r
-                errors.error(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage());\r
-                debug.debug(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage());\r
-\r
-            } catch (ProcessingException e) {\r
-                log.error(LogMessages.OPTIMIZER_EXCEPTION.toString(), e);\r
-                log.error(LogMessages.OPTIMIZER_EXCEPTION, e.getMessage());\r
+            CmsoOptimizerCallbackImpl.makeMap(startTime.getMillis(), latestInstanceStartTime.getMillis(),\r
+                            concurrencyLimit, totalDuration, nodeList, startAndFinishTimeMap);\r
+            for (String node : nodes.keySet()) {\r
+                Map<String, Long> map = startAndFinishTimeMap.get(node);\r
+                Long nodeStart = map.get("startTime");\r
+                Long nodeEnd = map.get("finishTime");\r
+                ScheduledElement se = new ScheduledElement();\r
+                se.setElementId(node);\r
+                se.setDurationSeconds((nodeEnd - nodeStart) / 1000); // in seconds\r
+                se.setStartTime(new Date(nodeStart));\r
+                se.setEndTime(new Date(nodeEnd));\r
+                se.setScheduleType(ScheduleType.INDIVIDUAL);\r
+                se.setGroupId(nodes.get(node));\r
+                scheduledList.add(se);\r
             }\r
         } catch (Exception e) {\r
-            errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());\r
-            debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());\r
+            Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());\r
+        }\r
 \r
+        return list;\r
+    }\r
+\r
+    @Override\r
+    public Response getOptimizerResponse(String id, UriInfo uri) {\r
+        //\r
+        try {\r
+            String rsp = optimizerResponses.get(id);\r
+            return Response.ok(rsp).build();\r
+        } catch (Exception e) {\r
+            log.error("Unexpected exception", e);\r
         }\r
+        return Response.serverError().build();\r
     }\r
 \r
+\r
+    @Override\r
     public Response soScheduleLoopback(String vnfName, String request, UriInfo uri) {\r
         String msoRequestId = env.getProperty("loopback.mso.requestId", "4ccbfb85-1d05-442e");\r
-        String r = UUID.randomUUID().toString();\r
+        String ruuid = UUID.randomUUID().toString();\r
         WfMsoRequestReferences rr = new WfMsoRequestReferences();\r
-        rr.setInstanceId(r);\r
+        rr.setInstanceId(ruuid);\r
         rr.setRequestId(msoRequestId);\r
         WfMsoResponse mso = new WfMsoResponse();\r
         mso.setRequestReferences(rr);\r
@@ -204,12 +189,13 @@ public class SchedulerTestLoopbackServiceImpl implements SchedulerTestLoopbackSe
     public Response soQueryLoopback(String requestId, UriInfo uri) {\r
         // Abbreviated response. Only interested in requestStatus....\r
         String response = "{\"request\" : {" + "\"requestId\" : \"dummy-request-id\","\r
-                + "\"startTime\" : \"Wed, 26 Aug 2017 06:36:07 GMT\"," + "\"requestScope\" : \"vfModule\","\r
-                + "\"requestType\" : \"createInstance\"," + "\"requestDetails\" : {}," + "\"instanceReferences\" : {},"\r
-                + "\"requestStatus\" : { " + "\"requestState\" : \"COMPLETE\","\r
-                + "\"statusMessage\" : \"Vf Module has been created successfully.\"," + "\"percentProgress\" : 100,"\r
-                + "\"finishTime\" : \"Crap so cmso uses current time\"}}}";\r
+                        + "\"startTime\" : \"Wed, 26 Aug 2017 06:36:07 GMT\"," + "\"requestScope\" : \"vfModule\","\r
+                        + "\"requestType\" : \"createInstance\"," + "\"requestDetails\" : {},"\r
+                        + "\"instanceReferences\" : {}," + "\"requestStatus\" : { " + "\"requestState\" : \"COMPLETE\","\r
+                        + "\"statusMessage\" : \"Vf Module has been created successfully.\","\r
+                        + "\"percentProgress\" : 100," + "\"finishTime\" : \"Crap so cmso uses current time\"}}}";\r
         return Response.ok().entity(response).build();\r
     }\r
 \r
+\r
 }\r
index d2953b6..f329cfc 100644 (file)
@@ -1,36 +1,37 @@
 /*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright � 2017-2018 AT&T Intellectual Property. Modifications Copyright � 2018 IBM.\r
  * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
  * \r
- *         http://www.apache.org/licenses/LICENSE-2.0\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
  * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
  * \r
  * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative\r
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
  * \r
- *         https://creativecommons.org/licenses/by/4.0/\r
+ * https://creativecommons.org/licenses/by/4.0/\r
  * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
+ * Unless required by applicable law or agreed to in writing, documentation distributed under the\r
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\r
+ * express or implied. See the License for the specific language governing permissions and\r
  * limitations under the License.\r
-*/\r
+ */\r
 \r
 package org.onap.optf.cmso.test.loopback;\r
 \r
+import com.fasterxml.jackson.databind.JsonNode;\r
+import io.swagger.annotations.Api;\r
+import io.swagger.annotations.ApiOperation;\r
+import io.swagger.annotations.ApiParam;\r
+import io.swagger.annotations.ApiResponse;\r
+import io.swagger.annotations.ApiResponses;\r
 import javax.ws.rs.POST;\r
 import javax.ws.rs.Path;\r
 import javax.ws.rs.Produces;\r
@@ -38,12 +39,6 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;\r
 import javax.ws.rs.core.Response;\r
 import javax.ws.rs.core.UriInfo;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import io.swagger.annotations.Api;\r
-import io.swagger.annotations.ApiOperation;\r
-import io.swagger.annotations.ApiParam;\r
-import io.swagger.annotations.ApiResponse;\r
-import io.swagger.annotations.ApiResponses;\r
 \r
 @Api\r
 @Path("/v1/tm")\r
@@ -56,7 +51,7 @@ public interface TicketMgtLoopbackService {
     @Produces({MediaType.APPLICATION_JSON})\r
     @ApiOperation(value = "", notes = "Dummy out ticket management check status call.", response = JsonNode.class)\r
     @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),\r
-            @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
+                    @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
     public Response tmGetChangeRecord(@ApiParam(value = "TM request message") JsonNode request, @Context UriInfo uri);\r
 \r
     // ******************************************************************\r
@@ -65,9 +60,9 @@ public interface TicketMgtLoopbackService {
     @Produces({MediaType.APPLICATION_JSON})\r
     @ApiOperation(value = "", notes = "Dummy out ticket management create call.", response = JsonNode.class)\r
     @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),\r
-            @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
+                    @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
     public Response tmCreateChangeRecord(@ApiParam(value = "TM request message") JsonNode request,\r
-            @Context UriInfo uri);\r
+                    @Context UriInfo uri);\r
 \r
     // ******************************************************************\r
     @POST\r
@@ -75,19 +70,19 @@ public interface TicketMgtLoopbackService {
     @Produces({MediaType.APPLICATION_JSON})\r
     @ApiOperation(value = "", notes = "Dummy out ticket management close call.", response = JsonNode.class)\r
     @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),\r
-            @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
+                    @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
     public Response tmCloseCancelChangeRecord(@ApiParam(value = "TM request message") JsonNode request,\r
-            @Context UriInfo uri);\r
+                    @Context UriInfo uri);\r
 \r
     // ******************************************************************\r
     @POST\r
     @Path("/updateChangeRecord")\r
     @Produces({MediaType.APPLICATION_JSON})\r
     @ApiOperation(value = "", notes = "Dummy out ticket management update to in progress call.",\r
-            response = JsonNode.class)\r
+                    response = JsonNode.class)\r
     @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"),\r
-            @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
+                    @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})\r
     public Response tmUpdateChangeRecord(@ApiParam(value = "TM request message") JsonNode request,\r
-            @Context UriInfo uri);\r
+                    @Context UriInfo uri);\r
 \r
 }\r