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)
306 public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
307 @PathVariable("vnfInstanceId") String vnfInstanceId,
308 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
309 String methodName = "deleteVnf";
311 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
312 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
313 MsoResponseWrapper w = msoBusinessLogic.deleteVnf(msoRequest, serviceInstanceId, vnfInstanceId);
315 // always return OK, the MSO status code is embedded in the body
316 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
320 * Delete configuration instance
322 * @param serviceInstanceId the service instance id
323 * @param configurationId the configuration id
324 * @param msoRequest the request
325 * @return the response entity
326 * @throws Exception the exception
328 @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
329 method = RequestMethod.POST)
330 public ResponseEntity<String> deleteConfiguration(
331 @PathVariable("serviceInstanceId") String serviceInstanceId,
332 @PathVariable("configurationId") String configurationId,
333 @RequestBody RequestDetailsWrapper msoRequest) {
335 String methodName = "deleteConfiguration";
336 LOGGER.debug(EELFLoggerDelegate.debugLogger,
337 "<== " + methodName + START_LOG);
339 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
340 MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(msoRequest, serviceInstanceId, configurationId);
342 // always return OK, the MSO status code is embedded in the body
343 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
347 * Activate configuration instance
349 * @param serviceInstanceId the service instace id
350 * @param configurationId the configuration id
351 * @param msoRequest the request
352 * @return the response entity
353 * @throws Exception the exception
355 @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
356 method = RequestMethod.POST)
357 public ResponseEntity<String> activateConfiguration(
358 @PathVariable("serviceInstanceId") String serviceInstanceId,
359 @PathVariable("configurationId") String configurationId,
360 @RequestBody RequestDetails msoRequest) {
362 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
363 MsoResponseWrapper w = msoBusinessLogic
364 .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, true);
366 // always return OK, the MSO status code is embedded in the body
367 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
371 * Deactivate configuration instance
373 * @param serviceInstanceId the service instace id
374 * @param configurationId the configuration id
375 * @param msoRequest the request
376 * @return the response entity
377 * @throws Exception the exception
379 @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
380 method = RequestMethod.POST)
381 public ResponseEntity<String> deactivateConfiguration(
382 @PathVariable("serviceInstanceId") String serviceInstanceId,
383 @PathVariable("configurationId") String configurationId,
384 @RequestBody RequestDetails msoRequest) {
386 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
387 MsoResponseWrapper w = msoBusinessLogic
388 .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, false);
390 // always return OK, the MSO status code is embedded in the body
391 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
395 * Disable port on configuration instance
397 * @param serviceInstanceId the service instance id
398 * @param configurationId the configuration instance id
399 * @param msoRequest the request
400 * @return the response entity
401 * @throws Exception the exception
403 @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
404 method = RequestMethod.POST)
405 public ResponseEntity<String> disablePortOnConfiguration(
406 @PathVariable("serviceInstanceId") String serviceInstanceId,
407 @PathVariable("configurationId") String configurationId,
408 @RequestBody RequestDetails msoRequest) {
410 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
411 MsoResponseWrapper w = msoBusinessLogic
412 .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, false);
414 // always return OK, the MSO status code is embedded in the body
415 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
419 * Enable port on configuration instance
421 * @param serviceInstanceId the service instance id
422 * @param configurationId the configuration instance id
423 * @param msoRequest the request
424 * @return the response entity
425 * @throws Exception the exception
427 @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
428 method = RequestMethod.POST)
429 public ResponseEntity<String> enablePortOnConfiguration(
430 @PathVariable("serviceInstanceId") String serviceInstanceId,
431 @PathVariable("configurationId") String configurationId,
432 @RequestBody RequestDetails msoRequest) {
434 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
435 MsoResponseWrapper w = msoBusinessLogic
436 .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, true);
438 // always return OK, the MSO status code is embedded in the body
439 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
445 * @param serviceInstanceId the service instance id
446 * @param vnfInstanceId the vnf instance id
447 * @param vfModuleId the vf module id
448 * @param request the request
449 * @return the response entity
450 * @throws Exception the exception
452 //mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
453 @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
454 public ResponseEntity<String> deleteVfModule(
455 @PathVariable("serviceInstanceId") String serviceInstanceId,
456 @PathVariable("vnfInstanceId") String vnfInstanceId,
457 @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request,
458 @RequestBody RequestDetails msoRequest) {
460 String methodName = "deleteVfModule";
461 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
463 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
464 MsoResponseWrapper w = msoBusinessLogic
465 .deleteVfModule(msoRequest, serviceInstanceId, vnfInstanceId, vfModuleId);
467 // always return OK, the MSO status code is embedded in the body
468 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
472 * Delete volume group instance.
474 * @param serviceInstanceId the service instance id
475 * @param vnfInstanceId the vnf instance id
476 * @param volumeGroupId the volume group id
477 * @param request the request
478 * @return the response entity
479 * @throws Exception the exception
481 @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
482 public ResponseEntity<String> deleteVolumeGroupInstance(
483 @PathVariable("serviceInstanceId") String serviceInstanceId,
484 @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
485 HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
486 String methodName = "deleteVolumeGroupInstance";
487 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
489 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
490 MsoResponseWrapper w = msoBusinessLogic
491 .deleteVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId, volumeGroupId);
493 // always return OK, the MSO status code is embedded in the body
494 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
498 * Delete nw instance.
500 * @param serviceInstanceId the service instance id
501 * @param networkInstanceId the network instance id
502 * @param request the request
503 * @return the response entity
504 * @throws Exception the exception
506 @RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
507 public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
508 @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request,
509 @RequestBody RequestDetails msoRequest) {
510 String methodName = "deleteNwInstance";
511 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
513 cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
514 MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(msoRequest, serviceInstanceId, networkInstanceId);
516 // always return OK, the MSO status code is embedded in the body
517 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
521 * Gets the orchestration request.
523 * @param requestId the request id
524 * @param request the request
525 * @return the orchestration request
526 * @throws Exception the exception
528 @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
529 public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
530 HttpServletRequest request) {
532 String methodName = "getOrchestrationRequest";
533 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
535 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
537 // always return OK, the MSO status code is embedded in the body
538 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
542 * Gets the orchestration requests.
544 * @param filterString the filter string
545 * @param request the request
546 * @return the orchestration requests
547 * @throws Exception the exception
549 @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
550 public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
551 HttpServletRequest request) {
553 String methodName = "getOrchestrationRequests";
554 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
556 MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
558 // always return OK, the MSO status code is embedded in the body
559 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
563 * activate to a pnf instance.
565 * @param serviceInstanceId the id of the service.
566 * @param requestDetails the body of the request.
567 * @return the response entity
568 * @throws Exception the exception
570 @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
571 public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
572 @RequestBody RequestDetails requestDetails) {
573 String methodName = "activateServiceInstance";
574 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
576 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
577 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
581 * deactivate a service instance.
583 * @param serviceInstanceId the id of the service.
584 * @param requestDetails the body of the request.
585 * @return the response entity
586 * @throws Exception the exception
588 @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
589 public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
590 @RequestBody RequestDetails requestDetails) {
591 String methodName = "deactivateServiceInstance";
592 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
594 MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
595 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
599 * Gets the orchestration requests for the dashboard.
600 * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
602 * @return the orchestration requests
603 * @throws Exception the exception
605 @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
606 public List<Request> getOrchestrationRequestsForDashboard() {
608 String methodName = "getOrchestrationRequestsForDashboard";
609 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
611 return msoBusinessLogic.getOrchestrationRequestsForDashboard();
615 * Gets the Manual Tasks for the given request id.
617 * @param originalRequestId the id of the original request.
619 * @throws Exception the exception
621 @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
622 public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) {
624 String methodName = "getManualTasksByRequestId";
625 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
627 return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
631 * Complete the manual task.
633 * @param taskId the id of the task to complete.
634 * @param requestDetails the body of the request.
635 * @return the response entity
636 * @throws Exception the exception
638 @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
639 public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId,
640 @RequestBody RequestDetails requestDetails) {
642 String methodName = "manualTaskComplete";
643 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
645 MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
646 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
649 @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
650 public ResponseEntity<String> removeRelationshipFromServiceInstance(
651 @PathVariable("serviceInstanceId") String serviceInstanceId,
652 @RequestBody RequestDetails requestDetails) {
654 String methodName = "removeRelationshipFromServiceInstance";
655 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
657 MsoResponseWrapper w;
659 w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
660 } catch (Exception e) {
661 LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
662 return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
664 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
667 @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
668 public ResponseEntity<String> addRelationshipToServiceInstance(
669 @PathVariable("serviceInstanceId") String serviceInstanceId,
670 @RequestBody RequestDetails requestDetails) {
672 String methodName = "addRelationshipToServiceInstance";
673 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
675 MsoResponseWrapper w;
677 w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
678 } catch (Exception e) {
679 LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
680 return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
682 return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
685 @RequestMapping(value = "/mso_activate_fabric_configuration/{serviceInstanceId}", method = RequestMethod.POST)
686 public MsoResponseWrapper2 activateFabricConfiguration(
687 @PathVariable("serviceInstanceId") String serviceInstanceId ,
688 @RequestBody RequestDetails requestDetails) {
690 String methodName = "activateFabricConfiguration";
691 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
693 String path = msoBusinessLogic.getActivateFabricConfigurationPath(serviceInstanceId);
694 RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetails, path, RequestReferencesContainer.class);
696 return new MsoResponseWrapper2<>(msoResponse);
699 @RequestMapping(value = "/mso_vfmodule_soft_delete/{serviceInstanceId}/{vnfInstanceId}/{vfModuleInstanceId}", method = RequestMethod.POST)
700 public MsoResponseWrapper2 deactivateAndCloudDelete(
701 @PathVariable("serviceInstanceId") String serviceInstanceId,
702 @PathVariable("vnfInstanceId") String vnfInstanceId,
703 @PathVariable("vfModuleInstanceId") String vfModuleInstanceId,
704 @RequestBody SoftDeleteRequest softDeleteRequest) {
706 String methodName = "deactivateAndCloudDelete";
707 LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
709 String path = msoBusinessLogic.getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId);
710 RequestDetails requestDetails = msoBusinessLogic.buildRequestDetailsForSoftDelete(softDeleteRequest);
712 cloudOwnerService.enrichRequestWithCloudOwner(requestDetails);
713 RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(new org.onap.vid.changeManagement.RequestDetailsWrapper<>(requestDetails), path, RequestReferencesContainer.class);
715 return new MsoResponseWrapper2<>(msoResponse);
722 * @param response the response
723 * @throws IOException Signals that an I/O exception has occurred.
725 @ExceptionHandler(Exception.class)
726 private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
728 ControllersUtils.handleException(e, LOGGER);
730 response.setContentType("application/json; charset=UTF-8");
731 response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
733 ExceptionResponse exceptionResponse = new ExceptionResponse();
734 exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
735 exceptionResponse.setMessage(e.getMessage());
737 response.getWriter().write(JACKSON_OBJECT_MAPPER.writeValueAsString(exceptionResponse));
739 response.flushBuffer();