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.MsoRestClientNew;
42 import org.onap.vid.mso.rest.Request;
43 import org.onap.vid.mso.rest.RequestDetails;
44 import org.onap.vid.mso.rest.RequestDetailsWrapper;
45 import org.onap.vid.mso.rest.Task;
46 import org.onap.vid.services.CloudOwnerService;
47 import org.springframework.beans.factory.annotation.Autowired;
48 import org.springframework.http.HttpStatus;
49 import org.springframework.http.ResponseEntity;
50 import org.springframework.web.bind.annotation.ExceptionHandler;
51 import org.springframework.web.bind.annotation.PathVariable;
52 import org.springframework.web.bind.annotation.RequestBody;
53 import org.springframework.web.bind.annotation.RequestMapping;
54 import org.springframework.web.bind.annotation.RequestMethod;
55 import org.springframework.web.bind.annotation.RequestParam;
56 import org.springframework.web.bind.annotation.RestController;
59 * The Class MsoController.
62 @RequestMapping("mso")
63 public class MsoController extends RestrictedBaseController {
68 private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
71 * The Constant SVC_INSTANCE_ID.
73 public static final String SVC_INSTANCE_ID = "<service_instance_id>";
74 public static final String REQUEST_TYPE = "<request_type>";
77 * The Constant CONFIGURATION_ID
79 public static final String CONFIGURATION_ID = "<configuration_id>";
82 * The Constant VNF_INSTANCE_ID.
84 public static final String VNF_INSTANCE_ID = "<vnf_instance_id>";
85 public static final String WORKFLOW_ID = "<workflow_UUID>";
86 public static final String START_LOG = " start";
88 private final MsoBusinessLogic msoBusinessLogic;
89 private final RestMsoImplementation restMso;
90 private final CloudOwnerService cloudOwnerService;
93 public MsoController(MsoBusinessLogic msoBusinessLogic, MsoRestClientNew msoClientInterface, CloudOwnerService cloudOwnerService) {
94 this.msoBusinessLogic = msoBusinessLogic;
95 this.restMso = msoClientInterface;
96 this.cloudOwnerService = cloudOwnerService;
100 * Creates the svc instance.
102 * @param request the request
103 * @return the response entity
104 * @throws Exception the exception
106 @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
107 public ResponseEntity<String> createSvcInstance(HttpServletRequest request,
108 @RequestBody RequestDetails msoRequest) {
109 String methodName = "createSvcInstance";
111 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
113 // always return OK, the MSO status code is embedded in the body
115 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
116 MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(msoRequest);
118 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
122 * Creates the e2e svc instance.
124 * @param request the request
125 * @return the response entity
126 * @throws Exception the exception
128 @RequestMapping(value = "/mso_create_e2e_svc_instance", method = RequestMethod.POST)
129 public ResponseEntity<String> createE2eSvcInstance(HttpServletRequest request,
130 @RequestBody LinkedHashMap<String, Object> msoRequest) {
131 String methodName = "createE2eSvcInstance";
133 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
135 // always return OK, the MSO status code is embedded in the body
137 //cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
138 MsoResponseWrapper w = msoBusinessLogic.createE2eSvcInstance(msoRequest.get("requestDetails"));
140 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
146 * @param serviceInstanceId the service instance id
147 * @param request the request
148 * @return the response entity
149 * @throws Exception the exception
151 @RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
152 public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
153 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
155 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
156 MsoResponseWrapper w = msoBusinessLogic.createVnf(msoRequest, serviceInstanceId);
158 // always return OK, the MSO status code is embedded in the body
160 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
164 * Creates the nw instance.
166 * @param serviceInstanceId the service instance id
167 * @param request the request
168 * @return the response entity
169 * @throws Exception the exception
171 @RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
172 public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
173 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
174 String methodName = "createNwInstance";
175 LOGGER.debug(EELFLoggerDelegate.debugLogger,
176 "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
178 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
179 MsoResponseWrapper w = msoBusinessLogic.createNwInstance(msoRequest, serviceInstanceId);
181 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
185 * Creates the volume group instance.
187 * @param serviceInstanceId the service instance id
188 * @param vnfInstanceId the vnf instance id
189 * @param request the request
190 * @return the response entity
191 * @throws Exception the exception
193 @RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
194 public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
195 @PathVariable("vnfInstanceId") String vnfInstanceId,
196 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
197 String methodName = "createVolumeGroupInstance";
198 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
200 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
201 MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId);
203 // always return OK, the MSO status code is embedded in the body
204 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
208 * Creates the vf module instance.
210 * @param serviceInstanceId the service instance id
211 * @param vnfInstanceId the vnf instance id
212 * @param request the request
213 * @return the response entity
214 * @throws Exception the exception
216 @RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
217 public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
218 @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request,
219 @RequestBody RequestDetails msoRequest) {
220 String methodName = "createVfModuleInstance";
222 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
224 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
225 MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(msoRequest, serviceInstanceId, vnfInstanceId);
227 // always return OK, the MSO status code is embedded in the body
229 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
233 * Creates a configuration instance.
235 * @param serviceInstanceId the service instance id
236 * @param request the request
237 * @return the response entity
238 * @throws Exception the exception
240 @RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
241 public ResponseEntity<String> createConfigurationInstance(
242 @PathVariable("serviceInstanceId") String serviceInstanceId,
243 HttpServletRequest request, @RequestBody RequestDetailsWrapper msoRequest) {
244 String methodName = "createConfigurationInstance";
245 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
247 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
248 MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(msoRequest, serviceInstanceId);
250 // always return OK, the MSO status code is embedded in the body
252 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
256 * Delete E2e svc instance.
258 * @param serviceInstanceId the service instance id
259 * @param request the request
260 * @return the response entity
261 * @throws Exception the exception
263 @RequestMapping(value = "/mso_delete_e2e_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
264 public ResponseEntity<String> deleteE2eSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
265 HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> msoRequest) {
267 LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), msoRequest);
268 MsoResponseWrapper w = msoBusinessLogic
269 .deleteE2eSvcInstance(msoRequest.get("requestDetails"), serviceInstanceId);
270 // always return OK, the MSO status code is embedded in the body
272 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
276 * Delete svc instance.
278 * @param serviceInstanceId the service instance id
279 * @param request the request
280 * @return the response entity
281 * @throws Exception the exception
283 @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
284 public String deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
285 HttpServletRequest request, @RequestBody RequestDetails msoRequest,
286 @RequestParam(value = "serviceStatus") String serviceStatus) {
288 LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), msoRequest);
289 MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(msoRequest, serviceInstanceId, serviceStatus);
290 // always return OK, the MSO status code is embedded in the body
292 return w.getResponse();
298 * @param serviceInstanceId the service instance id
299 * @param vnfInstanceId the vnf instance id
300 * @param request the request
301 * @return the response entity
302 * @throws Exception the exception
304 @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
305 public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
306 @PathVariable("vnfInstanceId") String vnfInstanceId,
307 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
308 String methodName = "deleteVnf";
310 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
311 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
312 MsoResponseWrapper w = msoBusinessLogic.deleteVnf(msoRequest, serviceInstanceId, vnfInstanceId);
314 // always return OK, the MSO status code is embedded in the body
315 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
319 * Delete configuration instance
321 * @param serviceInstanceId the service instance id
322 * @param configurationId the configuration id
323 * @param msoRequest the request
324 * @return the response entity
325 * @throws Exception the exception
327 @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
328 method = RequestMethod.POST)
329 public ResponseEntity<String> deleteConfiguration(
330 @PathVariable("serviceInstanceId") String serviceInstanceId,
331 @PathVariable("configurationId") String configurationId,
332 @RequestBody RequestDetailsWrapper msoRequest) {
334 String methodName = "deleteConfiguration";
335 LOGGER.debug(EELFLoggerDelegate.debugLogger,
336 "<== " + methodName + START_LOG);
338 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
339 MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(msoRequest, serviceInstanceId, configurationId);
341 // always return OK, the MSO status code is embedded in the body
342 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
346 * Activate configuration instance
348 * @param serviceInstanceId the service instace id
349 * @param configurationId the configuration id
350 * @param msoRequest the request
351 * @return the response entity
352 * @throws Exception the exception
354 @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
355 method = RequestMethod.POST)
356 public ResponseEntity<String> activateConfiguration(
357 @PathVariable("serviceInstanceId") String serviceInstanceId,
358 @PathVariable("configurationId") String configurationId,
359 @RequestBody RequestDetails msoRequest) {
361 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
362 MsoResponseWrapper w = msoBusinessLogic
363 .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, true);
365 // always return OK, the MSO status code is embedded in the body
366 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
370 * Deactivate configuration instance
372 * @param serviceInstanceId the service instace id
373 * @param configurationId the configuration id
374 * @param msoRequest the request
375 * @return the response entity
376 * @throws Exception the exception
378 @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
379 method = RequestMethod.POST)
380 public ResponseEntity<String> deactivateConfiguration(
381 @PathVariable("serviceInstanceId") String serviceInstanceId,
382 @PathVariable("configurationId") String configurationId,
383 @RequestBody RequestDetails msoRequest) {
385 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
386 MsoResponseWrapper w = msoBusinessLogic
387 .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, false);
389 // always return OK, the MSO status code is embedded in the body
390 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
394 * Disable port on configuration instance
396 * @param serviceInstanceId the service instance id
397 * @param configurationId the configuration instance id
398 * @param msoRequest the request
399 * @return the response entity
400 * @throws Exception the exception
402 @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
403 method = RequestMethod.POST)
404 public ResponseEntity<String> disablePortOnConfiguration(
405 @PathVariable("serviceInstanceId") String serviceInstanceId,
406 @PathVariable("configurationId") String configurationId,
407 @RequestBody RequestDetails msoRequest) {
409 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
410 MsoResponseWrapper w = msoBusinessLogic
411 .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, false);
413 // always return OK, the MSO status code is embedded in the body
414 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
418 * Enable port on configuration instance
420 * @param serviceInstanceId the service instance id
421 * @param configurationId the configuration instance id
422 * @param msoRequest the request
423 * @return the response entity
424 * @throws Exception the exception
426 @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
427 method = RequestMethod.POST)
428 public ResponseEntity<String> enablePortOnConfiguration(
429 @PathVariable("serviceInstanceId") String serviceInstanceId,
430 @PathVariable("configurationId") String configurationId,
431 @RequestBody RequestDetails msoRequest) {
433 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
434 MsoResponseWrapper w = msoBusinessLogic
435 .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, true);
437 // always return OK, the MSO status code is embedded in the body
438 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
444 * @param serviceInstanceId the service instance id
445 * @param vnfInstanceId the vnf instance id
446 * @param vfModuleId the vf module id
447 * @param request the request
448 * @return the response entity
449 * @throws Exception the exception
451 @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
452 public ResponseEntity<String> deleteVfModule(
453 @PathVariable("serviceInstanceId") String serviceInstanceId,
454 @PathVariable("vnfInstanceId") String vnfInstanceId,
455 @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request,
456 @RequestBody RequestDetails msoRequest) {
458 String methodName = "deleteVfModule";
459 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
461 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
462 MsoResponseWrapper w = msoBusinessLogic
463 .deleteVfModule(msoRequest, serviceInstanceId, vnfInstanceId, vfModuleId);
465 // always return OK, the MSO status code is embedded in the body
466 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
470 * Delete volume group instance.
472 * @param serviceInstanceId the service instance id
473 * @param vnfInstanceId the vnf instance id
474 * @param volumeGroupId the volume group id
475 * @param request the request
476 * @return the response entity
477 * @throws Exception the exception
479 @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
480 public ResponseEntity<String> deleteVolumeGroupInstance(
481 @PathVariable("serviceInstanceId") String serviceInstanceId,
482 @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
483 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
484 String methodName = "deleteVolumeGroupInstance";
485 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
487 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
488 MsoResponseWrapper w = msoBusinessLogic
489 .deleteVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId, volumeGroupId);
491 // always return OK, the MSO status code is embedded in the body
492 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
496 * Delete nw instance.
498 * @param serviceInstanceId the service instance id
499 * @param networkInstanceId the network instance id
500 * @param request the request
501 * @return the response entity
502 * @throws Exception the exception
504 @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
505 public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
506 @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request,
507 @RequestBody RequestDetails msoRequest) {
508 String methodName = "deleteNwInstance";
509 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
511 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
512 MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(msoRequest, serviceInstanceId, networkInstanceId);
514 // always return OK, the MSO status code is embedded in the body
515 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
519 * Gets the orchestration request.
521 * @param requestId the request id
522 * @param request the request
523 * @return the orchestration request
524 * @throws Exception the exception
526 @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
527 public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
528 HttpServletRequest request) {
530 String methodName = "getOrchestrationRequest";
531 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
533 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
535 // always return OK, the MSO status code is embedded in the body
536 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
540 * Gets the orchestration requests.
542 * @param filterString the filter string
543 * @param request the request
544 * @return the orchestration requests
545 * @throws Exception the exception
547 @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
548 public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
549 HttpServletRequest request) {
551 String methodName = "getOrchestrationRequests";
552 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
554 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
556 // always return OK, the MSO status code is embedded in the body
557 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
561 * activate to a pnf instance.
563 * @param serviceInstanceId the id of the service.
564 * @param requestDetails the body of the request.
565 * @return the response entity
566 * @throws Exception the exception
568 @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
569 public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
570 @RequestBody RequestDetails requestDetails) {
571 String methodName = "activateServiceInstance";
572 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
574 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
575 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
579 * deactivate a service instance.
581 * @param serviceInstanceId the id of the service.
582 * @param requestDetails the body of the request.
583 * @return the response entity
584 * @throws Exception the exception
586 @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
587 public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
588 @RequestBody RequestDetails requestDetails) {
589 String methodName = "deactivateServiceInstance";
590 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
592 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
593 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
597 * Gets the orchestration requests for the dashboard.
598 * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
600 * @return the orchestration requests
601 * @throws Exception the exception
603 @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
604 public List<Request> getOrchestrationRequestsForDashboard() {
606 String methodName = "getOrchestrationRequestsForDashboard";
607 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
609 return msoBusinessLogic.getOrchestrationRequestsForDashboard();
613 * Gets the Manual Tasks for the given request id.
615 * @param originalRequestId the id of the original request.
617 * @throws Exception the exception
619 @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
620 public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) {
622 String methodName = "getManualTasksByRequestId";
623 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
625 return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
629 * Complete the manual task.
631 * @param taskId the id of the task to complete.
632 * @param requestDetails the body of the request.
633 * @return the response entity
634 * @throws Exception the exception
636 @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
637 public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId,
638 @RequestBody RequestDetails requestDetails) {
640 String methodName = "manualTaskComplete";
641 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
643 MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
644 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
647 @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
648 public ResponseEntity<String> removeRelationshipFromServiceInstance(
649 @PathVariable("serviceInstanceId") String serviceInstanceId,
650 @RequestBody RequestDetails requestDetails) {
652 String methodName = "removeRelationshipFromServiceInstance";
653 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
655 MsoResponseWrapper w;
657 w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
658 } catch (Exception e) {
659 LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
660 return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
662 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
665 @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
666 public ResponseEntity<String> addRelationshipToServiceInstance(
667 @PathVariable("serviceInstanceId") String serviceInstanceId,
668 @RequestBody RequestDetails requestDetails) {
670 String methodName = "addRelationshipToServiceInstance";
671 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
673 MsoResponseWrapper w;
675 w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
676 } catch (Exception e) {
677 LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
678 return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
680 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
683 @RequestMapping(value = "/mso_activate_fabric_configuration/{serviceInstanceId}", method = RequestMethod.POST)
684 public MsoResponseWrapper2 activateFabricConfiguration(
685 @PathVariable("serviceInstanceId") String serviceInstanceId ,
686 @RequestBody RequestDetails requestDetails) {
688 String methodName = "activateFabricConfiguration";
689 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
691 String path = msoBusinessLogic.getActivateFabricConfigurationPath(serviceInstanceId);
692 RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetails, path, RequestReferencesContainer.class);
694 return new MsoResponseWrapper2<>(msoResponse);
697 @RequestMapping(value = "/mso_vfmodule_soft_delete/{serviceInstanceId}/{vnfInstanceId}/{vfModuleInstanceId}", method = RequestMethod.POST)
698 public MsoResponseWrapper2 deactivateAndCloudDelete(
699 @PathVariable("serviceInstanceId") String serviceInstanceId,
700 @PathVariable("vnfInstanceId") String vnfInstanceId,
701 @PathVariable("vfModuleInstanceId") String vfModuleInstanceId,
702 @RequestBody SoftDeleteRequest softDeleteRequest) {
704 String methodName = "deactivateAndCloudDelete";
705 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
707 String path = msoBusinessLogic.getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId);
708 RequestDetails requestDetails = msoBusinessLogic.buildRequestDetailsForSoftDelete(softDeleteRequest);
710 cloudOwnerService.enrichRequestWithCloudOwner(requestDetails);
711 RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(new org.onap.vid.changeManagement.RequestDetailsWrapper<>(requestDetails), path, RequestReferencesContainer.class);
713 return new MsoResponseWrapper2<>(msoResponse);
720 * @param response the response
721 * @throws IOException Signals that an I/O exception has occurred.
723 @ExceptionHandler(Exception.class)
724 private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
726 ControllersUtils.handleException(e, LOGGER);
728 response.setContentType("application/json; charset=UTF-8");
729 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
731 ExceptionResponse exceptionResponse = new ExceptionResponse();
732 exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
733 exceptionResponse.setMessage(e.getMessage());
735 response.getWriter().write(JACKSON_OBJECT_MAPPER.writeValueAsString(exceptionResponse));
737 response.flushBuffer();