Merge changes from topics "VID-30", "VID-37"
[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 - 2019 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 import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
24 import static org.onap.vid.utils.Logging.getMethodName;
25
26 import java.io.IOException;
27 import java.util.LinkedHashMap;
28 import java.util.List;
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse;
31 import org.onap.portalsdk.core.controller.RestrictedBaseController;
32 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
33 import org.onap.vid.model.ExceptionResponse;
34 import org.onap.vid.model.RequestReferencesContainer;
35 import org.onap.vid.model.SoftDeleteRequest;
36 import org.onap.vid.mso.MsoBusinessLogic;
37 import org.onap.vid.mso.MsoResponseWrapper;
38 import org.onap.vid.mso.MsoResponseWrapper2;
39 import org.onap.vid.mso.RestMsoImplementation;
40 import org.onap.vid.mso.RestObject;
41 import org.onap.vid.mso.rest.Request;
42 import org.onap.vid.mso.rest.RequestDetails;
43 import org.onap.vid.mso.rest.RequestDetailsWrapper;
44 import org.onap.vid.mso.rest.Task;
45 import org.onap.vid.services.CloudOwnerService;
46 import org.springframework.beans.factory.annotation.Autowired;
47 import org.springframework.http.HttpStatus;
48 import org.springframework.http.ResponseEntity;
49 import org.springframework.web.bind.annotation.ExceptionHandler;
50 import org.springframework.web.bind.annotation.PathVariable;
51 import org.springframework.web.bind.annotation.RequestBody;
52 import org.springframework.web.bind.annotation.RequestMapping;
53 import org.springframework.web.bind.annotation.RequestMethod;
54 import org.springframework.web.bind.annotation.RequestParam;
55 import org.springframework.web.bind.annotation.RestController;
56
57 /**
58  * The Class MsoController.
59  */
60 @RestController
61 @RequestMapping("mso")
62 public class MsoController extends RestrictedBaseController {
63
64     /**
65      * The logger.
66      */
67     private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
68
69     /**
70      * The Constant SVC_INSTANCE_ID.
71      */
72     public static final String SVC_INSTANCE_ID = "<service_instance_id>";
73     public static final String REQUEST_TYPE = "<request_type>";
74
75     /**
76      * The Constant CONFIGURATION_ID
77      */
78     public static final String CONFIGURATION_ID = "<configuration_id>";
79
80     /**
81      * The Constant VNF_INSTANCE_ID.
82      */
83     public static final String VNF_INSTANCE_ID = "<vnf_instance_id>";
84     public static final String WORKFLOW_ID = "<workflow_UUID>";
85     public static final String START_LOG = " start";
86
87     private final MsoBusinessLogic msoBusinessLogic;
88     private final RestMsoImplementation restMso;
89     private final CloudOwnerService cloudOwnerService;
90
91     @Autowired
92     public MsoController(MsoBusinessLogic msoBusinessLogic, RestMsoImplementation msoClientInterface, CloudOwnerService cloudOwnerService) {
93         this.msoBusinessLogic = msoBusinessLogic;
94         this.restMso = msoClientInterface;
95         this.cloudOwnerService = cloudOwnerService;
96     }
97
98     /**
99      * Creates the svc instance.
100      *
101      * @param request the request
102      * @return the response entity
103      * @throws Exception the exception
104      */
105     @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
106     public ResponseEntity<String> createSvcInstance(HttpServletRequest request,
107         @RequestBody RequestDetails msoRequest) {
108         String methodName = "createSvcInstance";
109
110         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
111
112         // always return OK, the MSO status code is embedded in the body
113
114         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
115         MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(msoRequest);
116
117         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
118     }
119
120     /**
121      * Creates the e2e svc instance.
122      *
123      * @param request the request
124      * @return the response entity
125      * @throws Exception the exception
126      */
127     @RequestMapping(value = "/mso_create_e2e_svc_instance", method = RequestMethod.POST)
128     public ResponseEntity<String> createE2eSvcInstance(HttpServletRequest request,
129         @RequestBody LinkedHashMap<String, Object> msoRequest) {
130         String methodName = "createE2eSvcInstance";
131
132         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
133
134         // always return OK, the MSO status code is embedded in the body
135
136         //cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
137         MsoResponseWrapper w = msoBusinessLogic.createE2eSvcInstance(msoRequest.get("requestDetails"));
138
139         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
140     }
141
142     /**
143      * Creates the vnf.
144      *
145      * @param serviceInstanceId the service instance id
146      * @param request the request
147      * @return the response entity
148      * @throws Exception the exception
149      */
150     @RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
151     public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
152         HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
153
154         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
155         MsoResponseWrapper w = msoBusinessLogic.createVnf(msoRequest, serviceInstanceId);
156
157         // always return OK, the MSO status code is embedded in the body
158
159         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
160     }
161
162     /**
163      * Creates the nw instance.
164      *
165      * @param serviceInstanceId the service instance id
166      * @param request the request
167      * @return the response entity
168      * @throws Exception the exception
169      */
170     @RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
171     public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
172         HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
173         String methodName = "createNwInstance";
174         LOGGER.debug(EELFLoggerDelegate.debugLogger,
175             "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
176
177         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
178         MsoResponseWrapper w = msoBusinessLogic.createNwInstance(msoRequest, serviceInstanceId);
179
180         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
181     }
182
183     /**
184      * Creates the volume group instance.
185      *
186      * @param serviceInstanceId the service instance id
187      * @param vnfInstanceId the vnf instance id
188      * @param request the request
189      * @return the response entity
190      * @throws Exception the exception
191      */
192     @RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
193     public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
194         @PathVariable("vnfInstanceId") String vnfInstanceId,
195         HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
196         String methodName = "createVolumeGroupInstance";
197         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
198
199         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
200         MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId);
201
202         // always return OK, the MSO status code is embedded in the body
203         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
204     }
205
206     /**
207      * Creates the vf module instance.
208      *
209      * @param serviceInstanceId the service instance id
210      * @param vnfInstanceId the vnf instance id
211      * @param request the request
212      * @return the response entity
213      * @throws Exception the exception
214      */
215     @RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
216     public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
217         @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request,
218         @RequestBody RequestDetails msoRequest) {
219         String methodName = "createVfModuleInstance";
220
221         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
222
223         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
224         MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(msoRequest, serviceInstanceId, vnfInstanceId);
225
226         // always return OK, the MSO status code is embedded in the body
227
228         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
229     }
230
231     /**
232      * Creates a configuration instance.
233      *
234      * @param serviceInstanceId the service instance id
235      * @param request the request
236      * @return the response entity
237      * @throws Exception the exception
238      */
239     @RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
240     public ResponseEntity<String> createConfigurationInstance(
241         @PathVariable("serviceInstanceId") String serviceInstanceId,
242         HttpServletRequest request, @RequestBody RequestDetailsWrapper msoRequest) {
243         String methodName = "createConfigurationInstance";
244         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
245
246         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
247         MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(msoRequest, serviceInstanceId);
248
249         // always return OK, the MSO status code is embedded in the body
250
251         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
252     }
253
254     /**
255      * Delete E2e svc instance.
256      *
257      * @param serviceInstanceId the service instance id
258      * @param request the request
259      * @return the response entity
260      * @throws Exception the exception
261      */
262     @RequestMapping(value = "/mso_delete_e2e_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
263     public ResponseEntity<String> deleteE2eSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
264         HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> msoRequest) {
265
266         LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), msoRequest);
267         MsoResponseWrapper w = msoBusinessLogic
268             .deleteE2eSvcInstance(msoRequest.get("requestDetails"), serviceInstanceId);
269         // always return OK, the MSO status code is embedded in the body
270
271         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
272     }
273
274     /**
275      * Delete svc instance.
276      *
277      * @param serviceInstanceId the service instance id
278      * @param request the request
279      * @return the response entity
280      * @throws Exception the exception
281      */
282     @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
283     public String deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
284         HttpServletRequest request, @RequestBody RequestDetails msoRequest,
285         @RequestParam(value = "serviceStatus") String serviceStatus) {
286
287         LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), msoRequest);
288         MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(msoRequest, serviceInstanceId, serviceStatus);
289         // always return OK, the MSO status code is embedded in the body
290
291         return w.getResponse();
292     }
293
294     /**
295      * Delete vnf.
296      *
297      * @param serviceInstanceId the service instance id
298      * @param vnfInstanceId the vnf instance id
299      * @param request the request
300      * @return the response entity
301      * @throws Exception the exception
302      */
303     @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
304     public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
305         @PathVariable("vnfInstanceId") String vnfInstanceId,
306         HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
307         String methodName = "deleteVnf";
308
309         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
310         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
311         MsoResponseWrapper w = msoBusinessLogic.deleteVnf(msoRequest, serviceInstanceId, vnfInstanceId);
312
313         // always return OK, the MSO status code is embedded in the body
314         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
315     }
316
317     /**
318      * Delete configuration instance
319      *
320      * @param serviceInstanceId the service instance id
321      * @param configurationId the configuration id
322      * @param msoRequest the request
323      * @return the response entity
324      * @throws Exception the exception
325      */
326     @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
327         method = RequestMethod.POST)
328     public ResponseEntity<String> deleteConfiguration(
329         @PathVariable("serviceInstanceId") String serviceInstanceId,
330         @PathVariable("configurationId") String configurationId,
331         @RequestBody RequestDetailsWrapper msoRequest) {
332
333         String methodName = "deleteConfiguration";
334         LOGGER.debug(EELFLoggerDelegate.debugLogger,
335             "<== " + methodName + START_LOG);
336
337         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
338         MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(msoRequest, serviceInstanceId, configurationId);
339
340         // always return OK, the MSO status code is embedded in the body
341         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
342     }
343
344     /**
345      * Activate configuration instance
346      *
347      * @param serviceInstanceId the service instace id
348      * @param configurationId the configuration id
349      * @param msoRequest the request
350      * @return the response entity
351      * @throws Exception the exception
352      */
353     @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
354         method = RequestMethod.POST)
355     public ResponseEntity<String> activateConfiguration(
356         @PathVariable("serviceInstanceId") String serviceInstanceId,
357         @PathVariable("configurationId") String configurationId,
358         @RequestBody RequestDetails msoRequest) {
359
360         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
361         MsoResponseWrapper w = msoBusinessLogic
362             .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, true);
363
364         // always return OK, the MSO status code is embedded in the body
365         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
366     }
367
368     /**
369      * Deactivate configuration instance
370      *
371      * @param serviceInstanceId the service instace id
372      * @param configurationId the configuration id
373      * @param msoRequest the request
374      * @return the response entity
375      * @throws Exception the exception
376      */
377     @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
378         method = RequestMethod.POST)
379     public ResponseEntity<String> deactivateConfiguration(
380         @PathVariable("serviceInstanceId") String serviceInstanceId,
381         @PathVariable("configurationId") String configurationId,
382         @RequestBody RequestDetails msoRequest) {
383
384         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
385         MsoResponseWrapper w = msoBusinessLogic
386             .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, false);
387
388         // always return OK, the MSO status code is embedded in the body
389         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
390     }
391
392     /**
393      * Disable port on configuration instance
394      *
395      * @param serviceInstanceId the service instance id
396      * @param configurationId the configuration instance id
397      * @param msoRequest the request
398      * @return the response entity
399      * @throws Exception the exception
400      */
401     @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
402         method = RequestMethod.POST)
403     public ResponseEntity<String> disablePortOnConfiguration(
404         @PathVariable("serviceInstanceId") String serviceInstanceId,
405         @PathVariable("configurationId") String configurationId,
406         @RequestBody RequestDetails msoRequest) {
407
408         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
409         MsoResponseWrapper w = msoBusinessLogic
410             .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, false);
411
412         // always return OK, the MSO status code is embedded in the body
413         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
414     }
415
416     /**
417      * Enable port on configuration instance
418      *
419      * @param serviceInstanceId the service instance id
420      * @param configurationId the configuration instance id
421      * @param msoRequest the request
422      * @return the response entity
423      * @throws Exception the exception
424      */
425     @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
426         method = RequestMethod.POST)
427     public ResponseEntity<String> enablePortOnConfiguration(
428         @PathVariable("serviceInstanceId") String serviceInstanceId,
429         @PathVariable("configurationId") String configurationId,
430         @RequestBody RequestDetails msoRequest) {
431
432         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
433         MsoResponseWrapper w = msoBusinessLogic
434             .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, true);
435
436         // always return OK, the MSO status code is embedded in the body
437         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
438     }
439
440     /**
441      * Delete vf module.
442      *
443      * @param serviceInstanceId the service instance id
444      * @param vnfInstanceId the vnf instance id
445      * @param vfModuleId the vf module id
446      * @param request the request
447      * @return the response entity
448      * @throws Exception the exception
449      */
450     @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
451     public ResponseEntity<String> deleteVfModule(
452         @PathVariable("serviceInstanceId") String serviceInstanceId,
453         @PathVariable("vnfInstanceId") String vnfInstanceId,
454         @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request,
455         @RequestBody RequestDetails msoRequest) {
456
457         String methodName = "deleteVfModule";
458         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
459
460         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
461         MsoResponseWrapper w = msoBusinessLogic
462             .deleteVfModule(msoRequest, serviceInstanceId, vnfInstanceId, vfModuleId);
463
464         // always return OK, the MSO status code is embedded in the body
465         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
466     }
467
468     /**
469      * Delete volume group instance.
470      *
471      * @param serviceInstanceId the service instance id
472      * @param vnfInstanceId the vnf instance id
473      * @param volumeGroupId the volume group id
474      * @param request the request
475      * @return the response entity
476      * @throws Exception the exception
477      */
478     @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
479     public ResponseEntity<String> deleteVolumeGroupInstance(
480         @PathVariable("serviceInstanceId") String serviceInstanceId,
481         @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
482         HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
483         String methodName = "deleteVolumeGroupInstance";
484         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
485
486         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
487         MsoResponseWrapper w = msoBusinessLogic
488             .deleteVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId, volumeGroupId);
489
490         // always return OK, the MSO status code is embedded in the body
491         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
492     }
493
494     /**
495      * Delete nw instance.
496      *
497      * @param serviceInstanceId the service instance id
498      * @param networkInstanceId the network instance id
499      * @param request the request
500      * @return the response entity
501      * @throws Exception the exception
502      */
503     @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
504     public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
505         @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request,
506         @RequestBody RequestDetails msoRequest) {
507         String methodName = "deleteNwInstance";
508         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
509
510         cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
511         MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(msoRequest, serviceInstanceId, networkInstanceId);
512
513         // always return OK, the MSO status code is embedded in the body
514         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
515     }
516
517     /**
518      * Gets the orchestration request.
519      *
520      * @param requestId the request id
521      * @param request the request
522      * @return the orchestration request
523      * @throws Exception the exception
524      */
525     @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
526     public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
527         HttpServletRequest request) {
528
529         String methodName = "getOrchestrationRequest";
530         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
531
532         MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
533
534         // always return OK, the MSO status code is embedded in the body
535         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
536     }
537
538     /**
539      * Gets the orchestration requests.
540      *
541      * @param filterString the filter string
542      * @param request the request
543      * @return the orchestration requests
544      * @throws Exception the exception
545      */
546     @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
547     public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
548         HttpServletRequest request) {
549
550         String methodName = "getOrchestrationRequests";
551         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
552
553         MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
554
555         // always return OK, the MSO status code is embedded in the body
556         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
557     }
558
559     /**
560      * activate to a pnf instance.
561      *
562      * @param serviceInstanceId the id of the service.
563      * @param requestDetails the body of the request.
564      * @return the response entity
565      * @throws Exception the exception
566      */
567     @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
568     public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
569         @RequestBody RequestDetails requestDetails) {
570         String methodName = "activateServiceInstance";
571         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
572
573         MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
574         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
575     }
576
577     /**
578      * deactivate a service instance.
579      *
580      * @param serviceInstanceId the id of the service.
581      * @param requestDetails the body of the request.
582      * @return the response entity
583      * @throws Exception the exception
584      */
585     @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
586     public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
587         @RequestBody RequestDetails requestDetails) {
588         String methodName = "deactivateServiceInstance";
589         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
590
591         MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
592         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
593     }
594
595     /**
596      * Gets the orchestration requests for the dashboard.
597      * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
598      *
599      * @return the orchestration requests
600      * @throws Exception the exception
601      */
602     @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
603     public List<Request> getOrchestrationRequestsForDashboard() {
604
605         String methodName = "getOrchestrationRequestsForDashboard";
606         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
607
608         return msoBusinessLogic.getOrchestrationRequestsForDashboard();
609     }
610
611     /**
612      * Gets the Manual Tasks for the given request id.
613      *
614      * @param originalRequestId the id of the original request.
615      * @return the tasks
616      * @throws Exception the exception
617      */
618     @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
619     public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) {
620
621         String methodName = "getManualTasksByRequestId";
622         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
623
624         return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
625     }
626
627     /**
628      * Complete the manual task.
629      *
630      * @param taskId the id of the task to complete.
631      * @param requestDetails the body of the request.
632      * @return the response entity
633      * @throws Exception the exception
634      */
635     @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
636     public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId,
637         @RequestBody RequestDetails requestDetails) {
638
639         String methodName = "manualTaskComplete";
640         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
641
642         MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
643         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
644     }
645
646     @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
647     public ResponseEntity<String> removeRelationshipFromServiceInstance(
648         @PathVariable("serviceInstanceId") String serviceInstanceId,
649         @RequestBody RequestDetails requestDetails) {
650
651         String methodName = "removeRelationshipFromServiceInstance";
652         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
653
654         MsoResponseWrapper w;
655         try {
656             w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
657         } catch (Exception e) {
658             LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
659             return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
660         }
661         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
662     }
663
664     @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
665     public ResponseEntity<String> addRelationshipToServiceInstance(
666         @PathVariable("serviceInstanceId") String serviceInstanceId,
667         @RequestBody RequestDetails requestDetails) {
668
669         String methodName = "addRelationshipToServiceInstance";
670         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
671
672         MsoResponseWrapper w;
673         try {
674             w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
675         } catch (Exception e) {
676             LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
677             return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
678         }
679         return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
680     }
681
682     @RequestMapping(value = "/mso_activate_fabric_configuration/{serviceInstanceId}", method = RequestMethod.POST)
683     public MsoResponseWrapper2 activateFabricConfiguration(
684             @PathVariable("serviceInstanceId") String serviceInstanceId ,
685             @RequestBody RequestDetails requestDetails) {
686
687         String methodName = "activateFabricConfiguration";
688         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
689
690         String path = msoBusinessLogic.getActivateFabricConfigurationPath(serviceInstanceId);
691         RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetails, path, RequestReferencesContainer.class);
692
693         return new MsoResponseWrapper2<>(msoResponse);
694     }
695
696     @RequestMapping(value = "/mso_vfmodule_soft_delete/{serviceInstanceId}/{vnfInstanceId}/{vfModuleInstanceId}", method = RequestMethod.POST)
697     public MsoResponseWrapper2 deactivateAndCloudDelete(
698             @PathVariable("serviceInstanceId") String serviceInstanceId,
699             @PathVariable("vnfInstanceId") String vnfInstanceId,
700             @PathVariable("vfModuleInstanceId") String vfModuleInstanceId,
701             @RequestBody SoftDeleteRequest softDeleteRequest) {
702
703         String methodName = "deactivateAndCloudDelete";
704         LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
705
706         String path = msoBusinessLogic.getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId);
707         RequestDetails requestDetails = msoBusinessLogic.buildRequestDetailsForSoftDelete(softDeleteRequest);
708
709         cloudOwnerService.enrichRequestWithCloudOwner(requestDetails);
710         RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(new org.onap.vid.changeManagement.RequestDetailsWrapper<>(requestDetails), path, RequestReferencesContainer.class);
711
712         return new MsoResponseWrapper2<>(msoResponse);
713     }
714
715     /**
716      * Exception handler.
717      *
718      * @param e the e
719      * @param response the response
720      * @throws IOException Signals that an I/O exception has occurred.
721      */
722     @ExceptionHandler(Exception.class)
723     private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
724
725         ControllersUtils.handleException(e, LOGGER);
726
727         response.setContentType("application/json; charset=UTF-8");
728         response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
729
730         ExceptionResponse exceptionResponse = new ExceptionResponse();
731         exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
732         exceptionResponse.setMessage(e.getMessage());
733
734         response.getWriter().write(JACKSON_OBJECT_MAPPER.writeValueAsString(exceptionResponse));
735
736         response.flushBuffer();
737     }
738 }