1 package org.openecomp.vid.controller;
3 import org.json.simple.JSONArray;
4 import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
5 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
6 import org.openecomp.vid.services.ChangeManagementService;
7 import org.openecomp.vid.services.WorkflowService;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.http.HttpStatus;
10 import org.springframework.http.ResponseEntity;
11 import org.springframework.web.bind.annotation.PathVariable;
12 import org.springframework.web.bind.annotation.RequestBody;
13 import org.springframework.web.bind.annotation.RequestMapping;
14 import org.springframework.web.bind.annotation.RequestMethod;
15 import org.springframework.web.bind.annotation.RequestParam;
16 import org.springframework.web.bind.annotation.RestController;
18 import org.openecomp.vid.changeManagement.ChangeManagementRequest;
19 import org.openecomp.vid.mso.rest.Request;
21 import java.io.IOException;
22 import java.util.Collection;
24 import javax.servlet.http.HttpServletRequest;
27 * Controller to handle ChangeManagement feature requests.
30 @RequestMapping("change-management")
31 public class ChangeManagementController extends UnRestrictedBaseController {
32 private EELFLoggerDelegate logger;
33 private String fromAppId;
34 private final WorkflowService workflowService;
35 private final ChangeManagementService changeManagementService;
38 public ChangeManagementController(WorkflowService workflowService, ChangeManagementService changeManagementService) {
39 this.logger = EELFLoggerDelegate.getLogger(ChangeManagementController.class);
40 this.fromAppId = "VidChangeManagementController";
41 this.workflowService = workflowService;
42 this.changeManagementService = changeManagementService;
45 @RequestMapping(value = {"/workflow"}, method = RequestMethod.GET)
46 public ResponseEntity<Collection<String>> getWorkflow(@RequestParam("vnfs") Collection<String> vnfs) throws IOException, InterruptedException {
47 Collection<String> result = this.workflowService.getWorkflowsForVNFs(vnfs);
48 return new ResponseEntity<>(result, HttpStatus.OK);
51 @RequestMapping(value = {"/mso"}, method = RequestMethod.GET)
52 public ResponseEntity<Collection<Request>> getMSOChangeManagements() throws IOException, InterruptedException {
53 Collection<Request> result = this.changeManagementService.getMSOChangeManagements();
54 return new ResponseEntity<>(result, HttpStatus.OK);
57 @RequestMapping(value = "/workflow/{vnfName}", method = RequestMethod.POST)
58 public ResponseEntity<String> changeManagement(@PathVariable("vnfName") String vnfName,
59 HttpServletRequest request,
60 @RequestBody ChangeManagementRequest changeManagmentRequest)
62 return this.changeManagementService.doChangeManagement(changeManagmentRequest, vnfName);
66 @RequestMapping(value = {"/scheduler"}, method = RequestMethod.GET)
67 public ResponseEntity<JSONArray> getSchedulerChangeManagements() throws IOException, InterruptedException {
68 JSONArray result = this.changeManagementService.getSchedulerChangeManagements();
69 return new ResponseEntity<>(result, HttpStatus.OK);