deebb2b704790b8bcf8ebdefa4e10770121fefab
[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 E2e 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_e2e_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
247     public ResponseEntity<String> deleteE2eSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
248                                                     HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> mso_request) throws Exception {
249
250         String methodName = "deleteE2eSvcInstance";
251         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
252
253         MsoResponseWrapper w = msoBusinessLogic.deleteE2eSvcInstance(mso_request.get("requestDetails"), 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 svc instance.
264      *
265      * @param serviceInstanceId the service instance id
266      * @param request           the request
267      * @return the response entity
268      * @throws Exception the exception
269      */
270     @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
271     public ResponseEntity<String> deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
272                                                     HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
273
274         String methodName = "deleteSvcInstance";
275         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
276
277         MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(mso_request, serviceInstanceId);
278
279         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
280         // always return OK, the MSO status code is embedded in the body
281
282         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
283
284     }
285
286     /**
287      * Delete vnf.
288      *
289      * @param serviceInstanceId the service instance id
290      * @param vnfInstanceId     the vnf instance id
291      * @param request           the request
292      * @return the response entity
293      * @throws Exception the exception
294      */
295     @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
296
297     public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
298                                             HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
299         String methodName = "deleteVnf";
300
301         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
302
303         MsoResponseWrapper w = msoBusinessLogic.deleteVnf(mso_request, serviceInstanceId, vnfInstanceId);
304
305         // always return OK, the MSO status code is embedded in the body
306         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
307
308     }
309
310     /**
311      * Delete configuration instance
312      * @param serviceInstanceId the service instance id
313      * @param configurationId the configuration id
314      * @param mso_request the request
315      * @return the response entity
316      * @throws Exception the exception
317      */
318     @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
319             method = RequestMethod.POST)
320     public ResponseEntity<String> deleteConfiguration(
321             @PathVariable("serviceInstanceId") String serviceInstanceId,
322             @PathVariable ("configurationId") String configurationId,
323             @RequestBody RequestDetails mso_request) throws Exception {
324
325         String methodName = "deleteConfiguration";
326         LOGGER.debug(EELFLoggerDelegate.debugLogger,
327                 dateFormat.format(new Date()) + "<== " + methodName + " start");
328
329         MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(mso_request, serviceInstanceId, configurationId);
330
331         // always return OK, the MSO status code is embedded in the body
332         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
333     }
334
335     /**
336      * Activate configuration instance
337      * @param serviceInstanceId the service instace id
338      * @param configurationId the configuration id
339      * @param mso_request the request
340      * @return the response entity
341      * @throws Exception the exception
342      */
343     @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
344             method = RequestMethod.POST)
345     public ResponseEntity<String> activateConfiguration(
346             @PathVariable("serviceInstanceId") String serviceInstanceId,
347             @PathVariable("configurationId") String configurationId,
348             @RequestBody RequestDetails mso_request) throws Exception {
349
350         MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, true);
351
352         // always return OK, the MSO status code is embedded in the body
353         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
354     }
355
356     /**
357      * Deactivate configuration instance
358      * @param serviceInstanceId the service instace id
359      * @param configurationId the configuration id
360      * @param mso_request the request
361      * @return the response entity
362      * @throws Exception the exception
363      */
364     @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
365             method = RequestMethod.POST)
366     public ResponseEntity<String> deactivateConfiguration(
367             @PathVariable("serviceInstanceId") String serviceInstanceId,
368             @PathVariable("configurationId") String configurationId,
369             @RequestBody RequestDetails mso_request) throws Exception {
370
371         MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, false);
372
373         // always return OK, the MSO status code is embedded in the body
374         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
375     }
376
377     /**
378      * Disable port on configuration instance
379      * @param serviceInstanceId the service instance id
380      * @param configurationId the configuration instance id
381      * @param mso_request the request
382      * @return the response entity
383      * @throws Exception the exception
384      */
385     @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
386             method = RequestMethod.POST)
387     public ResponseEntity<String> disablePortOnConfiguration(
388             @PathVariable("serviceInstanceId") String serviceInstanceId,
389             @PathVariable("configurationId") String configurationId,
390             @RequestBody RequestDetails mso_request) throws Exception {
391
392         MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, false);
393
394         // always return OK, the MSO status code is embedded in the body
395         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
396     }
397
398     /**
399      * Enable port on configuration instance
400      * @param serviceInstanceId the service instance id
401      * @param configurationId the configuration instance id
402      * @param mso_request the request
403      * @return the response entity
404      * @throws Exception the exception
405      */
406     @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
407             method = RequestMethod.POST)
408     public ResponseEntity<String> enablePortOnConfiguration(
409             @PathVariable("serviceInstanceId") String serviceInstanceId,
410             @PathVariable("configurationId") String configurationId,
411             @RequestBody RequestDetails mso_request) throws Exception {
412
413         MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, true);
414
415         // always return OK, the MSO status code is embedded in the body
416         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
417     }
418
419     /**
420      * Delete vf module.
421      *
422      * @param serviceInstanceId the service instance id
423      * @param vnfInstanceId     the vnf instance id
424      * @param vfModuleId        the vf module id
425      * @param request           the request
426      * @return the response entity
427      * @throws Exception the exception
428      */
429     //mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
430     @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
431     public ResponseEntity<String> deleteVfModule(
432             @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
433             @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
434
435         String methodName = "deleteVfModule";
436         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
437
438         MsoResponseWrapper w = msoBusinessLogic.deleteVfModule(mso_request, serviceInstanceId, vnfInstanceId, vfModuleId);
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     /**
446      * Delete volume group instance.
447      *
448      * @param serviceInstanceId the service instance id
449      * @param vnfInstanceId     the vnf instance id
450      * @param volumeGroupId     the volume group id
451      * @param request           the request
452      * @return the response entity
453      * @throws Exception the exception
454      */
455     @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
456     public ResponseEntity<String> deleteVolumeGroupInstance(
457             @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
458             HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
459         String methodName = "deleteVolumeGroupInstance";
460         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
461
462         MsoResponseWrapper w = msoBusinessLogic.deleteVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId, volumeGroupId);
463
464         // always return OK, the MSO status code is embedded in the body
465         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
466     }
467
468     /**
469      * Delete nw instance.
470      *
471      * @param serviceInstanceId the service instance id
472      * @param networkInstanceId the network instance id
473      * @param request           the request
474      * @return the response entity
475      * @throws Exception the exception
476      */
477     @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
478     public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
479                                                    @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
480         String methodName = "deleteNwInstance";
481         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
482
483         MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(mso_request, serviceInstanceId, networkInstanceId);
484
485         // always return OK, the MSO status code is embedded in the body
486         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
487
488     }
489
490     /**
491      * Gets the orchestration request.
492      *
493      * @param requestId the request id
494      * @param request   the request
495      * @return the orchestration request
496      * @throws Exception the exception
497      */
498     @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
499     public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
500                                                           HttpServletRequest request) throws Exception {
501
502         String methodName = "getOrchestrationRequest";
503         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
504
505
506         MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
507
508         // always return OK, the MSO status code is embedded in the body
509         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
510     }
511
512
513     /**
514      * Gets the orchestration requests.
515      *
516      * @param filterString the filter string
517      * @param request      the request
518      * @return the orchestration requests
519      * @throws Exception the exception
520      */
521     @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
522     public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
523                                                            HttpServletRequest request) throws Exception {
524
525         String methodName = "getOrchestrationRequests";
526         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
527
528
529         MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
530
531         // always return OK, the MSO status code is embedded in the body
532         return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
533     }
534
535
536     /**
537      * activate to a pnf instance.
538      *
539      * @param serviceInstanceId the id of the service.
540      * @param requestDetails the body of the request.
541      * @return the response entity
542      * @throws Exception the exception
543      */
544     @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
545     public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
546         String methodName = "activateServiceInstance";
547         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
548
549         MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
550         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
551     }
552
553     /**
554      * deactivate a service instance.
555      *
556      * @param serviceInstanceId the id of the service.
557      * @param requestDetails the body of the request.
558      * @return the response entity
559      * @throws Exception the exception
560      */
561     @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
562     public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
563         String methodName = "deactivateServiceInstance";
564         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
565
566         MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
567         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
568     }
569
570
571     /**
572      * Gets the orchestration requests for the dashboard.
573      *  currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
574      * @return the orchestration requests
575      * @throws Exception the exception
576      */
577     @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
578     public List<Request> getOrchestrationRequestsForDashboard() throws Exception {
579
580         String methodName = "getOrchestrationRequestsForDashboard";
581         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
582
583
584         return msoBusinessLogic.getOrchestrationRequestsForDashboard();
585     }
586
587     /**
588      * Gets the Manual Tasks for the given request id.
589      *
590      * @param originalRequestId the id of the original request.
591      * @return the tasks
592      * @throws Exception the exception
593      */
594     @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
595     public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) throws Exception {
596
597         String methodName = "getManualTasksByRequestId";
598         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
599
600         return  msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
601     }
602
603
604
605     /**
606      * Complete the manual task.
607      *
608      * @param taskId the id of the task to complete.
609      * @param requestDetails the body of the request.
610      * @return the response entity
611      * @throws Exception the exception
612      */
613     @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
614     public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId , @RequestBody RequestDetails requestDetails) throws Exception {
615
616         String methodName = "manualTaskComplete";
617         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
618
619         MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
620         return new ResponseEntity<String>(w.getResponse(), HttpStatus.OK);
621     }
622
623     @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
624     public ResponseEntity<String> removeRelationshipFromServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
625                                                                         @RequestBody RequestDetails requestDetails) throws Exception {
626
627         String methodName = "removeRelationshipFromServiceInstance";
628         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
629
630         MsoResponseWrapper w;
631         try {
632             w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
633         } catch (Exception e){
634             LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
635             return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
636         }
637         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
638     }
639
640     @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
641     public ResponseEntity<String> addRelationshipToServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
642                                                                         @RequestBody RequestDetails requestDetails) throws Exception {
643
644         String methodName = "addRelationshipToServiceInstance";
645         LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
646
647         MsoResponseWrapper w;
648         try {
649             w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
650         } catch (Exception e){
651             LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
652             return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
653         }
654         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
655     }
656
657
658     /**
659      * Exception handler.
660      *
661      * @param e        the e
662      * @param response the response
663      * @throws IOException Signals that an I/O exception has occurred.
664      */
665     @ExceptionHandler(Exception.class)
666     private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
667
668                 /*
669          * The following "logger.error" lines "should" be sufficient for logging the exception.
670                  * However, the console output in my Eclipse environment is NOT showing ANY of the
671                  * logger statements in this class. Thus the temporary "e.printStackTrace" statement
672                  * is also included.
673                  */
674
675         String methodName = "exceptionHandler";
676         LOGGER.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
677         StringWriter sw = new StringWriter();
678         e.printStackTrace(new PrintWriter(sw));
679         LOGGER.error(EELFLoggerDelegate.errorLogger, sw.toString());
680
681                 /*
682          *  Temporary - IF the above  mentioned "logger.error" glitch is resolved ...
683                  *  this statement could be removed since it would then likely result in duplicate
684                  *  trace output. 
685                  */
686         e.printStackTrace(System.err);
687
688         response.setContentType("application/json; charset=UTF-8");
689         response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
690
691         ExceptionResponse exceptionResponse = new ExceptionResponse();
692         exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
693         exceptionResponse.setMessage(e.getMessage());
694
695         response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
696
697         response.flushBuffer();
698
699     }
700
701 }