VoLTE support
[vid.git] / vid-app-common / src / main / java / org / onap / vid / controllers / MsoController.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.vid.controllers;
22
23
24 import com.fasterxml.jackson.databind.ObjectMapper;
25 import org.onap.vid.model.ExceptionResponse;
26 import org.onap.vid.mso.MsoBusinessLogic;
27 import org.onap.vid.mso.MsoResponseWrapper;
28 import org.onap.vid.mso.rest.Request;
29 import org.onap.vid.mso.rest.RequestDetails;
30 import org.onap.vid.mso.rest.Task;
31 import org.onap.portalsdk.core.controller.RestrictedBaseController;
32 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.http.HttpStatus;
35 import org.springframework.http.ResponseEntity;
36 import org.springframework.web.bind.annotation.*;
37
38 import javax.servlet.http.HttpServletRequest;
39 import javax.servlet.http.HttpServletResponse;
40 import java.io.IOException;
41 import java.io.PrintWriter;
42 import java.io.StringWriter;
43 import java.text.DateFormat;
44 import java.text.SimpleDateFormat;
45 import java.util.Date;
46 import java.util.LinkedHashMap;
47 import java.util.List;
48
49 //import java.util.UUID;
50 //import org.springframework.http.ResponseEntity;
51 //import org.springframework.http.RequestEntity;
52
53 /**
54  * The Class MsoController.
55  */
56 @RestController
57 @RequestMapping("mso")
58 public class MsoController extends RestrictedBaseController {
59
60     /**
61      * The logger.
62      */
63     private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
64
65     /**
66      * The Constant dateFormat.
67      */
68     final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
69
70     /**
71      * The Constant SVC_INSTANCE_ID.
72      */
73     public final static String SVC_INSTANCE_ID = "<service_instance_id>";
74     public final static String REQUEST_TYPE = "<request_type>";
75
76     /**
77      * The Constant CONFIGURATION_ID
78      */
79     public final static String CONFIGURATION_ID = "<configuration_id>";
80
81     /**
82      * The Constant VNF_INSTANCE_ID.
83      */
84     public final static String VNF_INSTANCE_ID = "<vnf_instance_id>";
85
86     private final MsoBusinessLogic msoBusinessLogic;
87
88     @Autowired
89     public MsoController(MsoBusinessLogic msoBusinessLogic) {
90         this.msoBusinessLogic = msoBusinessLogic;
91     }
92
93     /**
94      * Creates the svc instance.
95      *
96      * @param request the request
97      * @return the response entity
98      * @throws Exception the exception
99      */
100     @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
101     public ResponseEntity<String> createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
102         String methodName = "createSvcInstance";
103
104         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
105
106         // always return OK, the MSO status code is embedded in the body
107
108         MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(mso_request);
109
110         return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
111
112     }
113     
114     /**
115      * Creates the e2e svc instance.
116      *
117      * @param request the request
118      * @return the response entity
119      * @throws Exception the exception
120      */
121     @RequestMapping(value = "/mso_create_e2e_svc_instance", method = RequestMethod.POST)
122     public ResponseEntity<String> createE2eSvcInstance(HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> mso_request) throws Exception {
123         String methodName = "createE2eSvcInstance";
124
125         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
126
127         // always return OK, the MSO status code is embedded in the body
128
129         MsoResponseWrapper w = msoBusinessLogic.createE2eSvcInstance(mso_request.get("requestDetails"));
130
131         return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
132
133     }
134
135     /**
136      * Creates the vnf.
137      *
138      * @param serviceInstanceId the service instance id
139      * @param request           the request
140      * @return the response entity
141      * @throws Exception the exception
142      */
143     @RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
144     public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
145
146         MsoResponseWrapper w = msoBusinessLogic.createVnf(mso_request, serviceInstanceId);
147
148         // always return OK, the MSO status code is embedded in the body
149
150         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
151
152     }
153
154     /**
155      * Creates the nw instance.
156      *
157      * @param serviceInstanceId the service instance id
158      * @param request           the request
159      * @return the response entity
160      * @throws Exception the exception
161      */
162     @RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
163     public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
164         String methodName = "createNwInstance";
165         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
166
167         MsoResponseWrapper w = msoBusinessLogic.createNwInstance(mso_request, serviceInstanceId);
168
169         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
170
171     }
172
173     /**
174      * Creates the volume group instance.
175      *
176      * @param serviceInstanceId the service instance id
177      * @param vnfInstanceId     the vnf instance id
178      * @param request           the request
179      * @return the response entity
180      * @throws Exception the exception
181      */
182     @RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
183     public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
184                                                             HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
185         String methodName = "createVolumeGroupInstance";
186         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
187
188         MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId);
189
190         // always return OK, the MSO status code is embedded in the body
191         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
192     }
193
194     /**
195      * Creates the vf module instance.
196      *
197      * @param serviceInstanceId the service instance id
198      * @param vnfInstanceId     the vnf instance id
199      * @param request           the request
200      * @return the response entity
201      * @throws Exception the exception
202      */
203     @RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
204     public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
205                                                          @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
206         String methodName = "createVfModuleInstance";
207
208         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
209
210         MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(mso_request, serviceInstanceId, vnfInstanceId);
211
212         // always return OK, the MSO status code is embedded in the body
213
214         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
215     }
216
217     /**
218      * Creates a configuration instance.
219      *
220      * @param serviceInstanceId the service instance id
221      * @param request           the request
222      * @return the response entity
223      * @throws Exception the exception
224      */
225     @RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
226     public ResponseEntity<String> createConfigurationInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
227                                                          HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
228         String methodName = "createConfigurationInstance";
229         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
230
231         MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(mso_request, serviceInstanceId);
232
233         // always return OK, the MSO status code is embedded in the body
234
235         return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
236     }
237
238         /**
239      * Delete svc instance.
240      *
241      * @param serviceInstanceId the service instance id
242      * @param request           the request
243      * @return the response entity
244      * @throws Exception the exception
245      */
246     @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
247     public ResponseEntity<String> deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
248                                                     HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
249
250         String methodName = "deleteSvcInstance";
251         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
252
253         MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(mso_request, serviceInstanceId);
254
255         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
256         // always return OK, the MSO status code is embedded in the body
257
258         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
259
260     }
261
262     /**
263      * Delete vnf.
264      *
265      * @param serviceInstanceId the service instance id
266      * @param vnfInstanceId     the vnf instance id
267      * @param request           the request
268      * @return the response entity
269      * @throws Exception the exception
270      */
271     @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
272
273     public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
274                                             HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
275         String methodName = "deleteVnf";
276
277         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
278
279         MsoResponseWrapper w = msoBusinessLogic.deleteVnf(mso_request, serviceInstanceId, vnfInstanceId);
280
281         // always return OK, the MSO status code is embedded in the body
282         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
283
284     }
285
286     /**
287      * Delete configuration instance
288      * @param serviceInstanceId the service instance id
289      * @param configurationId the configuration id
290      * @param mso_request the request
291      * @return the response entity
292      * @throws Exception the exception
293      */
294     @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
295             method = RequestMethod.POST)
296     public ResponseEntity<String> deleteConfiguration(
297             @PathVariable("serviceInstanceId") String serviceInstanceId,
298             @PathVariable ("configurationId") String configurationId,
299             @RequestBody RequestDetails mso_request) throws Exception {
300
301         String methodName = "deleteConfiguration";
302         LOGGER.debug(EELFLoggerDelegate.debugLogger,
303                 dateFormat.format(new Date()) + "<== " + methodName + " start");
304
305         MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(mso_request, serviceInstanceId, configurationId);
306
307         // always return OK, the MSO status code is embedded in the body
308         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
309     }
310
311     /**
312      * Activate configuration instance
313      * @param serviceInstanceId the service instace id
314      * @param configurationId the configuration id
315      * @param mso_request the request
316      * @return the response entity
317      * @throws Exception the exception
318      */
319     @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
320             method = RequestMethod.POST)
321     public ResponseEntity<String> activateConfiguration(
322             @PathVariable("serviceInstanceId") String serviceInstanceId,
323             @PathVariable("configurationId") String configurationId,
324             @RequestBody RequestDetails mso_request) throws Exception {
325
326         MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, true);
327
328         // always return OK, the MSO status code is embedded in the body
329         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
330     }
331
332     /**
333      * Deactivate configuration instance
334      * @param serviceInstanceId the service instace id
335      * @param configurationId the configuration id
336      * @param mso_request the request
337      * @return the response entity
338      * @throws Exception the exception
339      */
340     @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
341             method = RequestMethod.POST)
342     public ResponseEntity<String> deactivateConfiguration(
343             @PathVariable("serviceInstanceId") String serviceInstanceId,
344             @PathVariable("configurationId") String configurationId,
345             @RequestBody RequestDetails mso_request) throws Exception {
346
347         MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, false);
348
349         // always return OK, the MSO status code is embedded in the body
350         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
351     }
352
353     /**
354      * Disable port on configuration instance
355      * @param serviceInstanceId the service instance id
356      * @param configurationId the configuration instance id
357      * @param mso_request the request
358      * @return the response entity
359      * @throws Exception the exception
360      */
361     @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
362             method = RequestMethod.POST)
363     public ResponseEntity<String> disablePortOnConfiguration(
364             @PathVariable("serviceInstanceId") String serviceInstanceId,
365             @PathVariable("configurationId") String configurationId,
366             @RequestBody RequestDetails mso_request) throws Exception {
367
368         MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, false);
369
370         // always return OK, the MSO status code is embedded in the body
371         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
372     }
373
374     /**
375      * Enable port on configuration instance
376      * @param serviceInstanceId the service instance id
377      * @param configurationId the configuration instance id
378      * @param mso_request the request
379      * @return the response entity
380      * @throws Exception the exception
381      */
382     @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
383             method = RequestMethod.POST)
384     public ResponseEntity<String> enablePortOnConfiguration(
385             @PathVariable("serviceInstanceId") String serviceInstanceId,
386             @PathVariable("configurationId") String configurationId,
387             @RequestBody RequestDetails mso_request) throws Exception {
388
389         MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, true);
390
391         // always return OK, the MSO status code is embedded in the body
392         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
393     }
394
395     /**
396      * Delete vf module.
397      *
398      * @param serviceInstanceId the service instance id
399      * @param vnfInstanceId     the vnf instance id
400      * @param vfModuleId        the vf module id
401      * @param request           the request
402      * @return the response entity
403      * @throws Exception the exception
404      */
405     //mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
406     @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
407     public ResponseEntity<String> deleteVfModule(
408             @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
409             @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
410
411         String methodName = "deleteVfModule";
412         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
413
414         MsoResponseWrapper w = msoBusinessLogic.deleteVfModule(mso_request, serviceInstanceId, vnfInstanceId, vfModuleId);
415
416         // always return OK, the MSO status code is embedded in the body
417         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
418
419     }
420
421     /**
422      * Delete volume group instance.
423      *
424      * @param serviceInstanceId the service instance id
425      * @param vnfInstanceId     the vnf instance id
426      * @param volumeGroupId     the volume group id
427      * @param request           the request
428      * @return the response entity
429      * @throws Exception the exception
430      */
431     @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
432     public ResponseEntity<String> deleteVolumeGroupInstance(
433             @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
434             HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
435         String methodName = "deleteVolumeGroupInstance";
436         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
437
438         MsoResponseWrapper w = msoBusinessLogic.deleteVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId, volumeGroupId);
439
440         // always return OK, the MSO status code is embedded in the body
441         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
442     }
443
444     /**
445      * Delete nw instance.
446      *
447      * @param serviceInstanceId the service instance id
448      * @param networkInstanceId the network instance id
449      * @param request           the request
450      * @return the response entity
451      * @throws Exception the exception
452      */
453     @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
454     public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
455                                                    @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
456         String methodName = "deleteNwInstance";
457         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
458
459         MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(mso_request, serviceInstanceId, networkInstanceId);
460
461         // always return OK, the MSO status code is embedded in the body
462         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
463
464     }
465
466     /**
467      * Gets the orchestration request.
468      *
469      * @param requestId the request id
470      * @param request   the request
471      * @return the orchestration request
472      * @throws Exception the exception
473      */
474     @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
475     public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
476                                                           HttpServletRequest request) throws Exception {
477
478         String methodName = "getOrchestrationRequest";
479         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
480
481
482         MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
483
484         // always return OK, the MSO status code is embedded in the body
485         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
486     }
487
488
489     /**
490      * Gets the orchestration requests.
491      *
492      * @param filterString the filter string
493      * @param request      the request
494      * @return the orchestration requests
495      * @throws Exception the exception
496      */
497     @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
498     public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
499                                                            HttpServletRequest request) throws Exception {
500
501         String methodName = "getOrchestrationRequests";
502         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
503
504
505         MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
506
507         // always return OK, the MSO status code is embedded in the body
508         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
509     }
510
511
512     /**
513      * activate to a pnf instance.
514      *
515      * @param serviceInstanceId the id of the service.
516      * @param requestDetails the body of the request.
517      * @return the response entity
518      * @throws Exception the exception
519      */
520     @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
521     public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
522         String methodName = "activateServiceInstance";
523         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
524
525         MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
526         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
527     }
528
529     /**
530      * deactivate a service instance.
531      *
532      * @param serviceInstanceId the id of the service.
533      * @param requestDetails the body of the request.
534      * @return the response entity
535      * @throws Exception the exception
536      */
537     @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
538     public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
539         String methodName = "deactivateServiceInstance";
540         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
541
542         MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
543         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
544     }
545
546
547     /**
548      * Gets the orchestration requests for the dashboard.
549      *  currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
550      * @return the orchestration requests
551      * @throws Exception the exception
552      */
553     @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
554     public List<Request> getOrchestrationRequestsForDashboard() throws Exception {
555
556         String methodName = "getOrchestrationRequestsForDashboard";
557         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
558
559
560         return msoBusinessLogic.getOrchestrationRequestsForDashboard();
561     }
562
563     /**
564      * Gets the Manual Tasks for the given request id.
565      *
566      * @param originalRequestId the id of the original request.
567      * @return the tasks
568      * @throws Exception the exception
569      */
570     @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
571     public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) throws Exception {
572
573         String methodName = "getManualTasksByRequestId";
574         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
575
576         return  msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
577     }
578
579
580
581     /**
582      * Complete the manual task.
583      *
584      * @param taskId the id of the task to complete.
585      * @param requestDetails the body of the request.
586      * @return the response entity
587      * @throws Exception the exception
588      */
589     @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
590     public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId , @RequestBody RequestDetails requestDetails) throws Exception {
591
592         String methodName = "manualTaskComplete";
593         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
594
595         MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
596         return new ResponseEntity<String>(w.getResponse(), HttpStatus.OK);
597     }
598
599     @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
600     public ResponseEntity<String> removeRelationshipFromServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
601                                                                         @RequestBody RequestDetails requestDetails) throws Exception {
602
603         String methodName = "removeRelationshipFromServiceInstance";
604         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
605
606         MsoResponseWrapper w;
607         try {
608             w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
609         } catch (Exception e){
610             LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
611             return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
612         }
613         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
614     }
615
616     @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
617     public ResponseEntity<String> addRelationshipToServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
618                                                                         @RequestBody RequestDetails requestDetails) throws Exception {
619
620         String methodName = "addRelationshipToServiceInstance";
621         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
622
623         MsoResponseWrapper w;
624         try {
625             w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
626         } catch (Exception e){
627             LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
628             return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
629         }
630         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
631     }
632
633
634     /**
635      * Exception handler.
636      *
637      * @param e        the e
638      * @param response the response
639      * @throws IOException Signals that an I/O exception has occurred.
640      */
641     @ExceptionHandler(Exception.class)
642     private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
643
644                 /*
645          * The following "logger.error" lines "should" be sufficient for logging the exception.
646                  * However, the console output in my Eclipse environment is NOT showing ANY of the
647                  * logger statements in this class. Thus the temporary "e.printStackTrace" statement
648                  * is also included.
649                  */
650
651         String methodName = "exceptionHandler";
652         LOGGER.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
653         StringWriter sw = new StringWriter();
654         e.printStackTrace(new PrintWriter(sw));
655         LOGGER.error(EELFLoggerDelegate.errorLogger, sw.toString());
656
657                 /*
658          *  Temporary - IF the above  mentioned "logger.error" glitch is resolved ...
659                  *  this statement could be removed since it would then likely result in duplicate
660                  *  trace output. 
661                  */
662         e.printStackTrace(System.err);
663
664         response.setContentType("application/json; charset=UTF-8");
665         response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
666
667         ExceptionResponse exceptionResponse = new ExceptionResponse();
668         exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
669         exceptionResponse.setMessage(e.getMessage());
670
671         response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
672
673         response.flushBuffer();
674
675     }
676
677 }