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