1 package org.openecomp.vid.services;
3 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
4 import org.openecomp.vid.changeManagement.ChangeManagementRequest;
5 import org.openecomp.vid.changeManagement.RequestDetails;
6 import org.openecomp.vid.mso.MsoBusinessLogic;
7 import org.openecomp.vid.mso.MsoResponseWrapper;
8 import org.openecomp.vid.controller.MsoController;
9 import org.openecomp.portalsdk.core.util.SystemProperties;
10 import org.openecomp.vid.scheduler.*;
12 import org.springframework.http.HttpStatus;
13 import org.springframework.http.ResponseEntity;
14 import org.openecomp.vid.mso.rest.Request;
15 import org.springframework.stereotype.Service;
16 import org.json.simple.JSONArray;
17 import org.json.simple.parser.JSONParser;
19 import java.util.Date;
20 import java.util.List;
21 import java.util.Collection;
25 public class ChangeManagementServiceImpl implements ChangeManagementService {
27 public Collection<Request> getMSOChangeManagements() {
28 Collection<Request> result = null;
29 MsoBusinessLogic msoBusinessLogic = new MsoBusinessLogic();
31 result = msoBusinessLogic.getOrchestrationRequestsForDashboard();
32 } catch (Exception e) {
39 private RequestDetails findRequestByVnfName(List<RequestDetails> requests, String vnfName){
44 for(RequestDetails requestDetails: requests){
45 if(requestDetails.getVnfName().equals(vnfName)){
46 return requestDetails;
54 public ResponseEntity<String> doChangeManagement(ChangeManagementRequest request, String vnfName) {
57 ResponseEntity<String> response = null;
58 RequestDetails currentRequestDetails = findRequestByVnfName(request.getRequestDetails(), vnfName);
59 MsoResponseWrapper msoResponseWrapperObject = null;
60 if(currentRequestDetails != null){
61 MsoBusinessLogic msoBusinessLogicObject = new MsoBusinessLogic();
62 String serviceInstanceId = currentRequestDetails.getRelatedInstList().get(0).getRelatedInstance().getInstanceId();
63 String vnfInstanceId = currentRequestDetails.getVnfInstanceId();
65 if (request.getRequestType().equalsIgnoreCase("update")) {
67 msoResponseWrapperObject = msoBusinessLogicObject.updateVnf(currentRequestDetails, serviceInstanceId, vnfInstanceId);
69 else if (request.getRequestType().equalsIgnoreCase("replace"))
71 msoResponseWrapperObject = msoBusinessLogicObject.replaceVnf(currentRequestDetails, serviceInstanceId, vnfInstanceId);
72 // throw new NotImplementedException();
74 response = new ResponseEntity<String>(msoResponseWrapperObject.getResponse(), HttpStatus.OK);
76 } catch (Exception e) {
82 // AH:TODO: return ChangeManagementResponse
87 public JSONArray getSchedulerChangeManagements() {
88 JSONArray result = null;
90 String path = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_GET_SCHEDULES);
91 org.openecomp.vid.scheduler.RestObject<String> restObject = new org.openecomp.vid.scheduler.RestObject<>();
92 SchedulerRestInterfaceIfc restClient = SchedulerRestInterfaceFactory.getInstance();
94 String str = new String();
96 restClient.Get(str, "", path, restObject);
97 String restCallResult = restObject.get();
98 JSONParser parser = new JSONParser();
99 Object parserResult = parser.parse(restCallResult);
100 result = (JSONArray) parserResult;
101 } catch (Exception e) {