2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.vid.controller;
23 import static org.onap.vid.utils.Logging.getMethodName;
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;
55 * The Class MsoController.
58 @RequestMapping("mso")
59 public class MsoController extends RestrictedBaseController {
64 private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
67 * The Constant SVC_INSTANCE_ID.
69 public static final String SVC_INSTANCE_ID = "<service_instance_id>";
70 public static final String REQUEST_TYPE = "<request_type>";
73 * The Constant CONFIGURATION_ID
75 public static final String CONFIGURATION_ID = "<configuration_id>";
78 * The Constant VNF_INSTANCE_ID.
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";
84 private final MsoBusinessLogic msoBusinessLogic;
85 private final CloudOwnerService cloudOwnerService;
88 public MsoController(MsoBusinessLogic msoBusinessLogic, CloudOwnerService cloudOwnerService) {
89 this.msoBusinessLogic = msoBusinessLogic;
90 this.cloudOwnerService = cloudOwnerService;
94 * Creates the svc instance.
96 * @param request the request
97 * @return the response entity
98 * @throws Exception the exception
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";
105 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
107 // always return OK, the MSO status code is embedded in the body
109 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
110 MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(msoRequest);
112 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
116 * Creates the e2e svc instance.
118 * @param request the request
119 * @return the response entity
120 * @throws Exception the exception
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";
127 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
129 // always return OK, the MSO status code is embedded in the body
131 //cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
132 MsoResponseWrapper w = msoBusinessLogic.createE2eSvcInstance(msoRequest.get("requestDetails"));
134 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
140 * @param serviceInstanceId the service instance id
141 * @param request the request
142 * @return the response entity
143 * @throws Exception the exception
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) {
149 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
150 MsoResponseWrapper w = msoBusinessLogic.createVnf(msoRequest, serviceInstanceId);
152 // always return OK, the MSO status code is embedded in the body
154 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
158 * Creates the nw instance.
160 * @param serviceInstanceId the service instance id
161 * @param request the request
162 * @return the response entity
163 * @throws Exception the exception
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);
172 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
173 MsoResponseWrapper w = msoBusinessLogic.createNwInstance(msoRequest, serviceInstanceId);
175 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
179 * Creates the volume group instance.
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
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);
194 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
195 MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId);
197 // always return OK, the MSO status code is embedded in the body
198 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
202 * Creates the vf module instance.
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
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";
216 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
218 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
219 MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(msoRequest, serviceInstanceId, vnfInstanceId);
221 // always return OK, the MSO status code is embedded in the body
223 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
227 * Creates a configuration instance.
229 * @param serviceInstanceId the service instance id
230 * @param request the request
231 * @return the response entity
232 * @throws Exception the exception
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);
241 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
242 MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(msoRequest, serviceInstanceId);
244 // always return OK, the MSO status code is embedded in the body
246 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
250 * Delete E2e svc instance.
252 * @param serviceInstanceId the service instance id
253 * @param request the request
254 * @return the response entity
255 * @throws Exception the exception
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) {
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
266 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
270 * Delete svc instance.
272 * @param serviceInstanceId the service instance id
273 * @param request the request
274 * @return the response entity
275 * @throws Exception the exception
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) {
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
286 return w.getResponse();
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
298 @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
300 public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
301 @PathVariable("vnfInstanceId") String vnfInstanceId,
302 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
303 String methodName = "deleteVnf";
305 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
306 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
307 MsoResponseWrapper w = msoBusinessLogic.deleteVnf(msoRequest, serviceInstanceId, vnfInstanceId);
309 // always return OK, the MSO status code is embedded in the body
310 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
314 * Delete configuration instance
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
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) {
329 String methodName = "deleteConfiguration";
330 LOGGER.debug(EELFLoggerDelegate.debugLogger,
331 "<== " + methodName + START_LOG);
333 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
334 MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(msoRequest, serviceInstanceId, configurationId);
336 // always return OK, the MSO status code is embedded in the body
337 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
341 * Activate configuration instance
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
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) {
356 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
357 MsoResponseWrapper w = msoBusinessLogic
358 .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, true);
360 // always return OK, the MSO status code is embedded in the body
361 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
365 * Deactivate configuration instance
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
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) {
380 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
381 MsoResponseWrapper w = msoBusinessLogic
382 .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, false);
384 // always return OK, the MSO status code is embedded in the body
385 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
389 * Disable port on configuration instance
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
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) {
404 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
405 MsoResponseWrapper w = msoBusinessLogic
406 .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, false);
408 // always return OK, the MSO status code is embedded in the body
409 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
413 * Enable port on configuration instance
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
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) {
428 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
429 MsoResponseWrapper w = msoBusinessLogic
430 .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, true);
432 // always return OK, the MSO status code is embedded in the body
433 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
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
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) {
454 String methodName = "deleteVfModule";
455 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
457 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
458 MsoResponseWrapper w = msoBusinessLogic
459 .deleteVfModule(msoRequest, serviceInstanceId, vnfInstanceId, vfModuleId);
461 // always return OK, the MSO status code is embedded in the body
462 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
466 * Delete volume group instance.
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
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);
483 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
484 MsoResponseWrapper w = msoBusinessLogic
485 .deleteVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId, volumeGroupId);
487 // always return OK, the MSO status code is embedded in the body
488 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
492 * Delete nw instance.
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
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);
507 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
508 MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(msoRequest, serviceInstanceId, networkInstanceId);
510 // always return OK, the MSO status code is embedded in the body
511 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
515 * Gets the orchestration request.
517 * @param requestId the request id
518 * @param request the request
519 * @return the orchestration request
520 * @throws Exception the exception
522 @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
523 public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
524 HttpServletRequest request) {
526 String methodName = "getOrchestrationRequest";
527 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
529 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
531 // always return OK, the MSO status code is embedded in the body
532 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
536 * Gets the orchestration requests.
538 * @param filterString the filter string
539 * @param request the request
540 * @return the orchestration requests
541 * @throws Exception the exception
543 @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
544 public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
545 HttpServletRequest request) {
547 String methodName = "getOrchestrationRequests";
548 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
550 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
552 // always return OK, the MSO status code is embedded in the body
553 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
557 * activate to a pnf instance.
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
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);
570 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
571 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
575 * deactivate a service instance.
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
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);
588 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
589 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
593 * Gets the orchestration requests for the dashboard.
594 * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
596 * @return the orchestration requests
597 * @throws Exception the exception
599 @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
600 public List<Request> getOrchestrationRequestsForDashboard() {
602 String methodName = "getOrchestrationRequestsForDashboard";
603 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
605 return msoBusinessLogic.getOrchestrationRequestsForDashboard();
609 * Gets the Manual Tasks for the given request id.
611 * @param originalRequestId the id of the original request.
613 * @throws Exception the exception
615 @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
616 public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) {
618 String methodName = "getManualTasksByRequestId";
619 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
621 return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
625 * Complete the manual task.
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
632 @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
633 public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId,
634 @RequestBody RequestDetails requestDetails) {
636 String methodName = "manualTaskComplete";
637 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
639 MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
640 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
643 @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
644 public ResponseEntity<String> removeRelationshipFromServiceInstance(
645 @PathVariable("serviceInstanceId") String serviceInstanceId,
646 @RequestBody RequestDetails requestDetails) {
648 String methodName = "removeRelationshipFromServiceInstance";
649 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
651 MsoResponseWrapper w;
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);
658 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
661 @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
662 public ResponseEntity<String> addRelationshipToServiceInstance(
663 @PathVariable("serviceInstanceId") String serviceInstanceId,
664 @RequestBody RequestDetails requestDetails) {
666 String methodName = "addRelationshipToServiceInstance";
667 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
669 MsoResponseWrapper w;
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);
676 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
679 @RequestMapping(value = "/mso_activate_fabric_configuration/{serviceInstanceId}", method = RequestMethod.POST)
680 public MsoResponseWrapper2 activateFabricConfiguration(
681 @PathVariable("serviceInstanceId") String serviceInstanceId,
682 @RequestBody RequestDetails requestDetails) {
684 String methodName = "activateFabricConfiguration";
685 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
687 return msoBusinessLogic.activateFabricConfiguration(serviceInstanceId, requestDetails);
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) {
697 String methodName = "deactivateAndCloudDelete";
698 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
700 RequestDetails requestDetails = msoBusinessLogic.buildRequestDetailsForSoftDelete(softDeleteRequest);
702 cloudOwnerService.enrichRequestWithCloudOwner(requestDetails);
703 return msoBusinessLogic
704 .deactivateAndCloudDelete(serviceInstanceId, vnfInstanceId, vfModuleInstanceId, requestDetails);
711 * @param response the response
712 * @throws IOException Signals that an I/O exception has occurred.
714 @ExceptionHandler(Exception.class)
715 private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
717 ControllersUtils.handleException(e, LOGGER);
719 response.setContentType("application/json; charset=UTF-8");
720 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
722 ExceptionResponse exceptionResponse = new ExceptionResponse();
723 exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
724 exceptionResponse.setMessage(e.getMessage());
726 response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
728 response.flushBuffer();