import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.changeManagement.*;
+import org.onap.vid.controller.ControllersUtils;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.exceptions.NotFoundException;
import org.onap.vid.model.VNFDao;
import org.onap.vid.model.VidWorkflow;
import org.onap.vid.mso.MsoBusinessLogic;
+import org.onap.vid.mso.MsoResponseWrapper;
import org.onap.vid.mso.MsoResponseWrapperInterface;
import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.RestObjectWithRequestInfo;
import org.onap.vid.mso.rest.Request;
import org.onap.vid.scheduler.SchedulerProperties;
import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
+import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
+import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.BadRequestException;
import java.io.IOException;
import java.util.*;
private MsoBusinessLogic msoBusinessLogic;
private final SchedulerRestInterfaceIfc restClient;
private final CloudOwnerService cloudOwnerService;
+ private final SystemPropertiesWrapper systemPropertiesWrapper;
@Autowired
private CsvService csvService;
@Autowired
- public ChangeManagementServiceImpl(DataAccessService dataAccessService, MsoBusinessLogic msoBusinessLogic, SchedulerRestInterfaceIfc schedulerRestInterface, CloudOwnerService cloudOwnerService) {
+ public ChangeManagementServiceImpl(DataAccessService dataAccessService, MsoBusinessLogic msoBusinessLogic, SchedulerRestInterfaceIfc schedulerRestInterface, CloudOwnerService cloudOwnerService, SystemPropertiesWrapper systemPropertiesWrapper) {
this.dataAccessService = dataAccessService;
this.msoBusinessLogic = msoBusinessLogic;
this.restClient = schedulerRestInterface;
this.cloudOwnerService = cloudOwnerService;
+ this.systemPropertiesWrapper = systemPropertiesWrapper;
}
@Override
}
}
-
- // AH:TODO: return ChangeManagementResponse
return null;
}
return currentRequestDetails.getVnfInstanceId();
}
- protected String extractServiceInstanceId(RequestDetails currentRequestDetails, String requestType) {
+ protected String extractServiceInstanceId(RequestDetails currentRequestDetails,
+ String requestType) {
try {
- String serviceInstanceId = currentRequestDetails.getRelatedInstList().get(0).getRelatedInstance().getInstanceId();
- serviceInstanceId.toString(); //throw exception in case that serviceInstanceId is null...
+ String serviceInstanceId = currentRequestDetails.getRelatedInstList().get(0)
+ .getRelatedInstance().getInstanceId();
+ if (serviceInstanceId == null) {
+ logger.error("Failed to extract serviceInstanceId");
+ throw new BadRequestException("No instanceId in request " + requestType);
+ }
return serviceInstanceId;
- } catch (Exception e) {
+ }
+ catch (Exception e) {
logger.error("Failed to extract serviceInstanceId");
throw new BadRequestException("No instanceId in request " + requestType);
}
dataAccessService.saveDomainObject(vnfList.get(0), null);
} catch (NonUniqueObjectException e) {
//In case the relation already exists, we continue running on the list
+ logger.debug("NonUniqueObjectException in addVnfWorkflowRelation", e);
}
}
return vnfWorkflowRelationResponse;
return json.toString();
}
+ @Override
+ public MsoResponseWrapper invokeVnfWorkflow(HttpServletRequest request,WorkflowRequestDetail requestBody, UUID serviceInstanceId, UUID vnfInstanceId, UUID workflow_UUID) {
+ String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(request);
+ return msoBusinessLogic.invokeVnfWorkflow(requestBody, userId, serviceInstanceId, vnfInstanceId, workflow_UUID);
+ }
+
private boolean validateJsonOutput(org.json.JSONObject json) {
- if (!json.has(PRIMARY_KEY) || !json.getJSONObject(PRIMARY_KEY).keySet().containsAll(REQUIRED_KEYS))
- return false;
- return true;
+ boolean isValid = true;
+ if (!json.has(PRIMARY_KEY)
+ || !json.getJSONObject(PRIMARY_KEY).keySet().containsAll(REQUIRED_KEYS)) {
+ isValid = false;
+ }
+ return isValid;
}
}