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.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
24 import static org.onap.vid.utils.Logging.getMethodName;
26 import java.io.IOException;
27 import java.util.LinkedHashMap;
28 import java.util.List;
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse;
31 import org.onap.portalsdk.core.controller.RestrictedBaseController;
32 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
33 import org.onap.vid.model.ExceptionResponse;
34 import org.onap.vid.model.RequestReferencesContainer;
35 import org.onap.vid.model.SoftDeleteRequest;
36 import org.onap.vid.mso.MsoBusinessLogic;
37 import org.onap.vid.mso.MsoResponseWrapper;
38 import org.onap.vid.mso.MsoResponseWrapper2;
39 import org.onap.vid.mso.RestMsoImplementation;
40 import org.onap.vid.mso.RestObject;
41 import org.onap.vid.mso.rest.Request;
42 import org.onap.vid.mso.rest.RequestDetails;
43 import org.onap.vid.mso.rest.RequestDetailsWrapper;
44 import org.onap.vid.mso.rest.Task;
45 import org.onap.vid.services.CloudOwnerService;
46 import org.springframework.beans.factory.annotation.Autowired;
47 import org.springframework.http.HttpStatus;
48 import org.springframework.http.ResponseEntity;
49 import org.springframework.web.bind.annotation.ExceptionHandler;
50 import org.springframework.web.bind.annotation.PathVariable;
51 import org.springframework.web.bind.annotation.RequestBody;
52 import org.springframework.web.bind.annotation.RequestMapping;
53 import org.springframework.web.bind.annotation.RequestMethod;
54 import org.springframework.web.bind.annotation.RequestParam;
55 import org.springframework.web.bind.annotation.RestController;
58 * The Class MsoController.
61 @RequestMapping("mso")
62 public class MsoController extends RestrictedBaseController {
67 private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
70 * The Constant SVC_INSTANCE_ID.
72 public static final String SVC_INSTANCE_ID = "<service_instance_id>";
73 public static final String REQUEST_TYPE = "<request_type>";
76 * The Constant CONFIGURATION_ID
78 public static final String CONFIGURATION_ID = "<configuration_id>";
81 * The Constant VNF_INSTANCE_ID.
83 public static final String VNF_INSTANCE_ID = "<vnf_instance_id>";
84 public static final String WORKFLOW_ID = "<workflow_UUID>";
85 public static final String START_LOG = " start";
87 private final MsoBusinessLogic msoBusinessLogic;
88 private final RestMsoImplementation restMso;
89 private final CloudOwnerService cloudOwnerService;
92 public MsoController(MsoBusinessLogic msoBusinessLogic, RestMsoImplementation msoClientInterface, CloudOwnerService cloudOwnerService) {
93 this.msoBusinessLogic = msoBusinessLogic;
94 this.restMso = msoClientInterface;
95 this.cloudOwnerService = cloudOwnerService;
99 * Creates the svc instance.
101 * @param request the request
102 * @return the response entity
103 * @throws Exception the exception
105 @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
106 public ResponseEntity<String> createSvcInstance(HttpServletRequest request,
107 @RequestBody RequestDetails msoRequest) {
108 String methodName = "createSvcInstance";
110 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
112 // always return OK, the MSO status code is embedded in the body
114 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
115 MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(msoRequest);
117 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
121 * Creates the e2e svc instance.
123 * @param request the request
124 * @return the response entity
125 * @throws Exception the exception
127 @RequestMapping(value = "/mso_create_e2e_svc_instance", method = RequestMethod.POST)
128 public ResponseEntity<String> createE2eSvcInstance(HttpServletRequest request,
129 @RequestBody LinkedHashMap<String, Object> msoRequest) {
130 String methodName = "createE2eSvcInstance";
132 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
134 // always return OK, the MSO status code is embedded in the body
136 //cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
137 MsoResponseWrapper w = msoBusinessLogic.createE2eSvcInstance(msoRequest.get("requestDetails"));
139 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
145 * @param serviceInstanceId the service instance id
146 * @param request the request
147 * @return the response entity
148 * @throws Exception the exception
150 @RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
151 public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
152 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
154 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
155 MsoResponseWrapper w = msoBusinessLogic.createVnf(msoRequest, serviceInstanceId);
157 // always return OK, the MSO status code is embedded in the body
159 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
163 * Creates the nw instance.
165 * @param serviceInstanceId the service instance id
166 * @param request the request
167 * @return the response entity
168 * @throws Exception the exception
170 @RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
171 public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
172 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
173 String methodName = "createNwInstance";
174 LOGGER.debug(EELFLoggerDelegate.debugLogger,
175 "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
177 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
178 MsoResponseWrapper w = msoBusinessLogic.createNwInstance(msoRequest, serviceInstanceId);
180 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
184 * Creates the volume group instance.
186 * @param serviceInstanceId the service instance id
187 * @param vnfInstanceId the vnf instance id
188 * @param request the request
189 * @return the response entity
190 * @throws Exception the exception
192 @RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
193 public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
194 @PathVariable("vnfInstanceId") String vnfInstanceId,
195 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
196 String methodName = "createVolumeGroupInstance";
197 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
199 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
200 MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId);
202 // always return OK, the MSO status code is embedded in the body
203 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
207 * Creates the vf module instance.
209 * @param serviceInstanceId the service instance id
210 * @param vnfInstanceId the vnf instance id
211 * @param request the request
212 * @return the response entity
213 * @throws Exception the exception
215 @RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
216 public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
217 @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request,
218 @RequestBody RequestDetails msoRequest) {
219 String methodName = "createVfModuleInstance";
221 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
223 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
224 MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(msoRequest, serviceInstanceId, vnfInstanceId);
226 // always return OK, the MSO status code is embedded in the body
228 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
232 * Creates a configuration instance.
234 * @param serviceInstanceId the service instance id
235 * @param request the request
236 * @return the response entity
237 * @throws Exception the exception
239 @RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
240 public ResponseEntity<String> createConfigurationInstance(
241 @PathVariable("serviceInstanceId") String serviceInstanceId,
242 HttpServletRequest request, @RequestBody RequestDetailsWrapper msoRequest) {
243 String methodName = "createConfigurationInstance";
244 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
246 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
247 MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(msoRequest, serviceInstanceId);
249 // always return OK, the MSO status code is embedded in the body
251 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
255 * Delete E2e svc instance.
257 * @param serviceInstanceId the service instance id
258 * @param request the request
259 * @return the response entity
260 * @throws Exception the exception
262 @RequestMapping(value = "/mso_delete_e2e_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
263 public ResponseEntity<String> deleteE2eSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
264 HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> msoRequest) {
266 LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), msoRequest);
267 MsoResponseWrapper w = msoBusinessLogic
268 .deleteE2eSvcInstance(msoRequest.get("requestDetails"), serviceInstanceId);
269 // always return OK, the MSO status code is embedded in the body
271 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
275 * Delete svc instance.
277 * @param serviceInstanceId the service instance id
278 * @param request the request
279 * @return the response entity
280 * @throws Exception the exception
282 @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
283 public String deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
284 HttpServletRequest request, @RequestBody RequestDetails msoRequest,
285 @RequestParam(value = "serviceStatus") String serviceStatus) {
287 LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), msoRequest);
288 MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(msoRequest, serviceInstanceId, serviceStatus);
289 // always return OK, the MSO status code is embedded in the body
291 return w.getResponse();
297 * @param serviceInstanceId the service instance id
298 * @param vnfInstanceId the vnf instance id
299 * @param request the request
300 * @return the response entity
301 * @throws Exception the exception
303 @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
304 public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
305 @PathVariable("vnfInstanceId") String vnfInstanceId,
306 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
307 String methodName = "deleteVnf";
309 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
310 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
311 MsoResponseWrapper w = msoBusinessLogic.deleteVnf(msoRequest, serviceInstanceId, vnfInstanceId);
313 // always return OK, the MSO status code is embedded in the body
314 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
318 * Delete configuration instance
320 * @param serviceInstanceId the service instance id
321 * @param configurationId the configuration id
322 * @param msoRequest the request
323 * @return the response entity
324 * @throws Exception the exception
326 @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
327 method = RequestMethod.POST)
328 public ResponseEntity<String> deleteConfiguration(
329 @PathVariable("serviceInstanceId") String serviceInstanceId,
330 @PathVariable("configurationId") String configurationId,
331 @RequestBody RequestDetailsWrapper msoRequest) {
333 String methodName = "deleteConfiguration";
334 LOGGER.debug(EELFLoggerDelegate.debugLogger,
335 "<== " + methodName + START_LOG);
337 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
338 MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(msoRequest, serviceInstanceId, configurationId);
340 // always return OK, the MSO status code is embedded in the body
341 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
345 * Activate configuration instance
347 * @param serviceInstanceId the service instace id
348 * @param configurationId the configuration id
349 * @param msoRequest the request
350 * @return the response entity
351 * @throws Exception the exception
353 @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
354 method = RequestMethod.POST)
355 public ResponseEntity<String> activateConfiguration(
356 @PathVariable("serviceInstanceId") String serviceInstanceId,
357 @PathVariable("configurationId") String configurationId,
358 @RequestBody RequestDetails msoRequest) {
360 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
361 MsoResponseWrapper w = msoBusinessLogic
362 .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, true);
364 // always return OK, the MSO status code is embedded in the body
365 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
369 * Deactivate configuration instance
371 * @param serviceInstanceId the service instace id
372 * @param configurationId the configuration id
373 * @param msoRequest the request
374 * @return the response entity
375 * @throws Exception the exception
377 @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
378 method = RequestMethod.POST)
379 public ResponseEntity<String> deactivateConfiguration(
380 @PathVariable("serviceInstanceId") String serviceInstanceId,
381 @PathVariable("configurationId") String configurationId,
382 @RequestBody RequestDetails msoRequest) {
384 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
385 MsoResponseWrapper w = msoBusinessLogic
386 .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, false);
388 // always return OK, the MSO status code is embedded in the body
389 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
393 * Disable port on configuration instance
395 * @param serviceInstanceId the service instance id
396 * @param configurationId the configuration instance id
397 * @param msoRequest the request
398 * @return the response entity
399 * @throws Exception the exception
401 @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
402 method = RequestMethod.POST)
403 public ResponseEntity<String> disablePortOnConfiguration(
404 @PathVariable("serviceInstanceId") String serviceInstanceId,
405 @PathVariable("configurationId") String configurationId,
406 @RequestBody RequestDetails msoRequest) {
408 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
409 MsoResponseWrapper w = msoBusinessLogic
410 .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, false);
412 // always return OK, the MSO status code is embedded in the body
413 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
417 * Enable port on configuration instance
419 * @param serviceInstanceId the service instance id
420 * @param configurationId the configuration instance id
421 * @param msoRequest the request
422 * @return the response entity
423 * @throws Exception the exception
425 @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
426 method = RequestMethod.POST)
427 public ResponseEntity<String> enablePortOnConfiguration(
428 @PathVariable("serviceInstanceId") String serviceInstanceId,
429 @PathVariable("configurationId") String configurationId,
430 @RequestBody RequestDetails msoRequest) {
432 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
433 MsoResponseWrapper w = msoBusinessLogic
434 .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, true);
436 // always return OK, the MSO status code is embedded in the body
437 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
443 * @param serviceInstanceId the service instance id
444 * @param vnfInstanceId the vnf instance id
445 * @param vfModuleId the vf module id
446 * @param request the request
447 * @return the response entity
448 * @throws Exception the exception
450 @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
451 public ResponseEntity<String> deleteVfModule(
452 @PathVariable("serviceInstanceId") String serviceInstanceId,
453 @PathVariable("vnfInstanceId") String vnfInstanceId,
454 @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request,
455 @RequestBody RequestDetails msoRequest) {
457 String methodName = "deleteVfModule";
458 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
460 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
461 MsoResponseWrapper w = msoBusinessLogic
462 .deleteVfModule(msoRequest, serviceInstanceId, vnfInstanceId, vfModuleId);
464 // always return OK, the MSO status code is embedded in the body
465 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
469 * Delete volume group instance.
471 * @param serviceInstanceId the service instance id
472 * @param vnfInstanceId the vnf instance id
473 * @param volumeGroupId the volume group id
474 * @param request the request
475 * @return the response entity
476 * @throws Exception the exception
478 @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
479 public ResponseEntity<String> deleteVolumeGroupInstance(
480 @PathVariable("serviceInstanceId") String serviceInstanceId,
481 @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
482 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
483 String methodName = "deleteVolumeGroupInstance";
484 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
486 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
487 MsoResponseWrapper w = msoBusinessLogic
488 .deleteVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId, volumeGroupId);
490 // always return OK, the MSO status code is embedded in the body
491 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
495 * Delete nw instance.
497 * @param serviceInstanceId the service instance id
498 * @param networkInstanceId the network instance id
499 * @param request the request
500 * @return the response entity
501 * @throws Exception the exception
503 @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
504 public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
505 @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request,
506 @RequestBody RequestDetails msoRequest) {
507 String methodName = "deleteNwInstance";
508 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
510 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
511 MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(msoRequest, serviceInstanceId, networkInstanceId);
513 // always return OK, the MSO status code is embedded in the body
514 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
518 * Gets the orchestration request.
520 * @param requestId the request id
521 * @param request the request
522 * @return the orchestration request
523 * @throws Exception the exception
525 @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
526 public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
527 HttpServletRequest request) {
529 String methodName = "getOrchestrationRequest";
530 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
532 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
534 // always return OK, the MSO status code is embedded in the body
535 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
539 * Gets the orchestration requests.
541 * @param filterString the filter string
542 * @param request the request
543 * @return the orchestration requests
544 * @throws Exception the exception
546 @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
547 public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
548 HttpServletRequest request) {
550 String methodName = "getOrchestrationRequests";
551 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
553 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
555 // always return OK, the MSO status code is embedded in the body
556 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
560 * activate to a pnf instance.
562 * @param serviceInstanceId the id of the service.
563 * @param requestDetails the body of the request.
564 * @return the response entity
565 * @throws Exception the exception
567 @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
568 public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
569 @RequestBody RequestDetails requestDetails) {
570 String methodName = "activateServiceInstance";
571 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
573 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
574 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
578 * deactivate a service instance.
580 * @param serviceInstanceId the id of the service.
581 * @param requestDetails the body of the request.
582 * @return the response entity
583 * @throws Exception the exception
585 @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
586 public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
587 @RequestBody RequestDetails requestDetails) {
588 String methodName = "deactivateServiceInstance";
589 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
591 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
592 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
596 * Gets the orchestration requests for the dashboard.
597 * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
599 * @return the orchestration requests
600 * @throws Exception the exception
602 @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
603 public List<Request> getOrchestrationRequestsForDashboard() {
605 String methodName = "getOrchestrationRequestsForDashboard";
606 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
608 return msoBusinessLogic.getOrchestrationRequestsForDashboard();
612 * Gets the Manual Tasks for the given request id.
614 * @param originalRequestId the id of the original request.
616 * @throws Exception the exception
618 @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
619 public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) {
621 String methodName = "getManualTasksByRequestId";
622 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
624 return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
628 * Complete the manual task.
630 * @param taskId the id of the task to complete.
631 * @param requestDetails the body of the request.
632 * @return the response entity
633 * @throws Exception the exception
635 @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
636 public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId,
637 @RequestBody RequestDetails requestDetails) {
639 String methodName = "manualTaskComplete";
640 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
642 MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
643 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
646 @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
647 public ResponseEntity<String> removeRelationshipFromServiceInstance(
648 @PathVariable("serviceInstanceId") String serviceInstanceId,
649 @RequestBody RequestDetails requestDetails) {
651 String methodName = "removeRelationshipFromServiceInstance";
652 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
654 MsoResponseWrapper w;
656 w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
657 } catch (Exception e) {
658 LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
659 return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
661 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
664 @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
665 public ResponseEntity<String> addRelationshipToServiceInstance(
666 @PathVariable("serviceInstanceId") String serviceInstanceId,
667 @RequestBody RequestDetails requestDetails) {
669 String methodName = "addRelationshipToServiceInstance";
670 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
672 MsoResponseWrapper w;
674 w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
675 } catch (Exception e) {
676 LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
677 return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
679 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
682 @RequestMapping(value = "/mso_activate_fabric_configuration/{serviceInstanceId}", method = RequestMethod.POST)
683 public MsoResponseWrapper2 activateFabricConfiguration(
684 @PathVariable("serviceInstanceId") String serviceInstanceId ,
685 @RequestBody RequestDetails requestDetails) {
687 String methodName = "activateFabricConfiguration";
688 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
690 String path = msoBusinessLogic.getActivateFabricConfigurationPath(serviceInstanceId);
691 RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetails, path, RequestReferencesContainer.class);
693 return new MsoResponseWrapper2<>(msoResponse);
696 @RequestMapping(value = "/mso_vfmodule_soft_delete/{serviceInstanceId}/{vnfInstanceId}/{vfModuleInstanceId}", method = RequestMethod.POST)
697 public MsoResponseWrapper2 deactivateAndCloudDelete(
698 @PathVariable("serviceInstanceId") String serviceInstanceId,
699 @PathVariable("vnfInstanceId") String vnfInstanceId,
700 @PathVariable("vfModuleInstanceId") String vfModuleInstanceId,
701 @RequestBody SoftDeleteRequest softDeleteRequest) {
703 String methodName = "deactivateAndCloudDelete";
704 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
706 String path = msoBusinessLogic.getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId);
707 RequestDetails requestDetails = msoBusinessLogic.buildRequestDetailsForSoftDelete(softDeleteRequest);
709 cloudOwnerService.enrichRequestWithCloudOwner(requestDetails);
710 RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(new org.onap.vid.changeManagement.RequestDetailsWrapper<>(requestDetails), path, RequestReferencesContainer.class);
712 return new MsoResponseWrapper2<>(msoResponse);
719 * @param response the response
720 * @throws IOException Signals that an I/O exception has occurred.
722 @ExceptionHandler(Exception.class)
723 private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
725 ControllersUtils.handleException(e, LOGGER);
727 response.setContentType("application/json; charset=UTF-8");
728 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
730 ExceptionResponse exceptionResponse = new ExceptionResponse();
731 exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
732 exceptionResponse.setMessage(e.getMessage());
734 response.getWriter().write(JACKSON_OBJECT_MAPPER.writeValueAsString(exceptionResponse));
736 response.flushBuffer();