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