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