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