VfModule and VolumeGroup RequestParameters: introduce objects hierarchy
[vid.git] / vid-app-common / src / main / java / org / onap / vid / controller / ChangeManagementController.java
index 4f307ed..cf855f3 100644 (file)
@@ -1,11 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 - 2019 Nokia. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
 package org.onap.vid.controller;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.commons.lang3.tuple.Pair;
-import org.json.simple.JSONArray;
-import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.onap.vid.changeManagement.*;
 import org.onap.vid.exceptions.NotFoundException;
 import org.onap.vid.model.ExceptionResponse;
@@ -23,7 +45,6 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.WebApplicationException;
-import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
 
@@ -36,7 +57,6 @@ import static org.springframework.http.HttpStatus.*;
 @RestController
 @RequestMapping(ChangeManagementController.CHANGE_MANAGEMENT)
 public class ChangeManagementController extends UnRestrictedBaseController {
-    private static final String GetWorkflowsResponse = null;
     public static final String VNF_WORKFLOW_RELATION = "vnf_workflow_relation";
     public static final String CHANGE_MANAGEMENT = "change-management";
     public static final String GET_VNF_WORKFLOW_RELATION = "get_vnf_workflow_relation";
@@ -57,21 +77,21 @@ public class ChangeManagementController extends UnRestrictedBaseController {
     }
 
     @RequestMapping(value = {"/workflow"}, method = RequestMethod.GET)
-    public ResponseEntity<Collection<String>> getWorkflow(@RequestParam("vnfs") Collection<String> vnfs) throws IOException, InterruptedException {
+    public ResponseEntity<Collection<String>> getWorkflow(@RequestParam("vnfs") Collection<String> vnfs) {
         Collection<String> result = this.workflowService.getWorkflowsForVNFs(vnfs);
         return new ResponseEntity<>(result, OK);
     }
 
     @RequestMapping(value = {"/mso"}, method = RequestMethod.GET)
-    public ResponseEntity<Collection<Request>> getMSOChangeManagements() throws Exception, IOException, InterruptedException {
+    public ResponseEntity<Collection<Request>> getMSOChangeManagements() {
 
         Collection<Request> result = this.changeManagementService.getMSOChangeManagements();
         return new ResponseEntity<>(result, OK);
     }
 
     @RequestMapping(value = "/workflow/{vnfName}", method = RequestMethod.POST)
-    public ResponseEntity<String> changeManagement(@PathVariable("vnfName") String vnfName,
-                                                   HttpServletRequest request,
+    public ResponseEntity<String> changeManagement(HttpServletRequest request,
+                                                   @PathVariable("vnfName") String vnfName,
                                                    @RequestBody ChangeManagementRequest changeManagmentRequest)
             throws Exception {
         return this.changeManagementService.doChangeManagement(changeManagmentRequest, vnfName);
@@ -94,20 +114,20 @@ public class ChangeManagementController extends UnRestrictedBaseController {
 
 
     @RequestMapping(value = {"/scheduler"}, method = RequestMethod.GET)
-    public ResponseEntity<JSONArray> getSchedulerChangeManagements() throws IOException, InterruptedException {
-        JSONArray result = this.changeManagementService.getSchedulerChangeManagements();
+    public ResponseEntity<ArrayNode> getSchedulerChangeManagements() {
+        ArrayNode result = this.changeManagementService.getSchedulerChangeManagements();
         return new ResponseEntity<>(result, OK);
     }
 
     @RequestMapping(value = {SCHEDULER_BY_SCHEDULE_ID}, method = RequestMethod.DELETE)
-    public ResponseEntity deleteSchedule(@PathVariable("scheduleId") String scheduleId) throws IOException, InterruptedException {
+    public ResponseEntity deleteSchedule(@PathVariable("scheduleId") String scheduleId) {
         Pair<String, Integer> result = this.changeManagementService.deleteSchedule(scheduleId);
         return ResponseEntity.status(result.getRight()).build();
     }
 
     
     @RequestMapping(value = {GET_VNF_WORKFLOW_RELATION}, method = RequestMethod.POST)
-    public ResponseEntity getWorkflows(@RequestBody GetVnfWorkflowRelationRequest getVnfWorkflowRelationRequest) throws IOException, InterruptedException {
+    public ResponseEntity getWorkflows(@RequestBody GetVnfWorkflowRelationRequest getVnfWorkflowRelationRequest) {
         try {
             GetWorkflowsResponse response = new GetWorkflowsResponse(changeManagementService.getWorkflowsForVnf(getVnfWorkflowRelationRequest));
             return ResponseEntity.status(OK).body(response);
@@ -122,7 +142,7 @@ public class ChangeManagementController extends UnRestrictedBaseController {
     }
     
     @RequestMapping(value = {VNF_WORKFLOW_RELATION}, method = RequestMethod.POST)
-    public ResponseEntity createWorkflowRelation(@RequestBody VnfWorkflowRelationRequest vnfWorkflowRelationRequest) throws IOException, InterruptedException {
+    public ResponseEntity createWorkflowRelation(@RequestBody VnfWorkflowRelationRequest vnfWorkflowRelationRequest) {
        VnfWorkflowRelationResponse vnfWorkflowRelationResponse;
         try {
             vnfWorkflowRelationResponse = changeManagementService.addVnfWorkflowRelation(vnfWorkflowRelationRequest);
@@ -135,7 +155,7 @@ public class ChangeManagementController extends UnRestrictedBaseController {
     }
 
     @RequestMapping(value = {VNF_WORKFLOW_RELATION}, method = RequestMethod.GET)
-    public ResponseEntity getAllWorkflowRelation() throws IOException, InterruptedException {
+    public ResponseEntity getAllWorkflowRelation() {
 
         try {
             VnfWorkflowRelationAllResponse vnfWorkflowRelationAllResponse = changeManagementService.getAllVnfWorkflowRelations();
@@ -147,7 +167,7 @@ public class ChangeManagementController extends UnRestrictedBaseController {
     }
     
     @RequestMapping(value = {VNF_WORKFLOW_RELATION}, method = RequestMethod.DELETE)
-    public ResponseEntity deleteWorkflowRelation(@RequestBody VnfWorkflowRelationRequest vnfWorkflowRelationRequest) throws IOException, InterruptedException {
+    public ResponseEntity deleteWorkflowRelation(@RequestBody VnfWorkflowRelationRequest vnfWorkflowRelationRequest) {
        VnfWorkflowRelationResponse vnfWorkflowRelationResponse;
        try {
                vnfWorkflowRelationResponse = changeManagementService.deleteVnfWorkflowRelation(vnfWorkflowRelationRequest);
@@ -186,8 +206,7 @@ public class ChangeManagementController extends UnRestrictedBaseController {
 
     private MsoResponseWrapperInterface exceptionHandler(Exception e, HttpStatus httpStatus) {
         LOGGER.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodName(), ExceptionUtils.getMessage(e), e);
-        MsoResponseWrapper2<MsoExceptionResponse> responseWrapper2 = new MsoResponseWrapper2<>(httpStatus.value(), new MsoExceptionResponse(e));
-        return responseWrapper2;
+        return new MsoResponseWrapper2<>(httpStatus.value(), new MsoExceptionResponse(e));
     }
 
 }