summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java185
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java259
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java39
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java69
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java173
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java22
8 files changed, 514 insertions, 245 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
index 6013677684..897e2a5fc8 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
@@ -44,5 +44,7 @@ public enum Action implements Actions{
scaleInstance,
deactivateAndCloudDelete,
scaleOut,
- recreateInstance
+ recreateInstance,
+ addMembers,
+ removeMembers
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index c9f32d9705..440a9ea3ee 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -44,6 +44,7 @@ import javax.xml.transform.stream.StreamResult;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest;
+import org.onap.so.apihandlerinfra.validation.MembersValidation;
import org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation;
import org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation;
import org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation;
@@ -174,6 +175,8 @@ public class MsoRequest {
rules.add(new InPlaceSoftwareUpdateValidation());
}else if(reqVersion >= 6 && action == Action.applyUpdatedConfig){
rules.add(new ApplyUpdatedConfigValidation());
+ }else if(action == Action.addMembers || action == Action.removeMembers){
+ rules.add(new MembersValidation());
}else{
rules.add(new RequestScopeValidation());
rules.add(new RequestParametersValidation());
@@ -264,7 +267,6 @@ public class MsoRequest {
if (null == servInsReq) {
servInsReq = new ServiceInstancesRequest ();
}
-
String networkType = "";
String vnfType = "";
aq.setRequestId (requestId);
@@ -275,97 +277,104 @@ public class MsoRequest {
Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
aq.setStartTime (startTimeStamp);
- RequestInfo requestInfo =servInsReq.getRequestDetails().getRequestInfo();
- if (requestInfo != null) {
-
- if(requestInfo.getSource() != null){
- aq.setSource(requestInfo.getSource());
- }
- if(requestInfo.getCallbackUrl() != null){
- aq.setCallBackUrl(requestInfo.getCallbackUrl());
- }
- if(requestInfo.getCorrelator() != null){
- aq.setCorrelator(requestInfo.getCorrelator());
- }
-
- if(requestInfo.getRequestorId() != null) {
- aq.setRequestorId(requestInfo.getRequestorId());
- }
- }
-
- if (servInsReq.getRequestDetails().getModelInfo() != null || (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig)) {
+ if(requestScope.equals(ModelType.instanceGroup.name()) && action == Action.deleteInstance){
aq.setRequestScope(requestScope);
- }
-
- if (servInsReq.getRequestDetails().getCloudConfiguration() != null) {
- CloudConfiguration cloudConfiguration = servInsReq.getRequestDetails().getCloudConfiguration();
- if(cloudConfiguration.getLcpCloudRegionId() != null) {
- aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId());
- }
-
- if(cloudConfiguration.getTenantId() != null) {
- aq.setTenantId(cloudConfiguration.getTenantId());
- }
-
- }
-
- if(servInsReq.getServiceInstanceId() != null){
- aq.setServiceInstanceId(servInsReq.getServiceInstanceId());
- }
-
- if(servInsReq.getVnfInstanceId() != null){
- aq.setVnfId(servInsReq.getVnfInstanceId());
- }
-
- if(ModelType.service.name().equalsIgnoreCase(requestScope)){
- if(servInsReq.getRequestDetails().getRequestInfo().getInstanceName() != null){
- aq.setServiceInstanceName(requestInfo.getInstanceName());
- }
- }
-
- if(ModelType.network.name().equalsIgnoreCase(requestScope)){
- aq.setNetworkName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
- aq.setNetworkType(networkType);
- aq.setNetworkId(servInsReq.getNetworkInstanceId());
- }
-
- if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)){
- aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
- aq.setVolumeGroupName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
- aq.setVnfType(vnfType);
-
- }
-
- if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)){
- aq.setVfModuleName(requestInfo.getInstanceName());
- aq.setVfModuleModelName(servInsReq.getRequestDetails().getModelInfo().getModelName());
- aq.setVfModuleId(servInsReq.getVfModuleInstanceId());
- aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
- aq.setVnfType(vnfType);
-
- }
-
- if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
- aq.setConfigurationId(servInsReq.getConfigurationId());
- aq.setConfigurationName(requestInfo.getInstanceName());
- }
-
- if(ModelType.vnf.name().equalsIgnoreCase(requestScope)){
- aq.setVnfName(requestInfo.getInstanceName());
- if (null != servInsReq.getRequestDetails()) {
- RelatedInstanceList[] instanceList = servInsReq.getRequestDetails().getRelatedInstanceList();
-
- if (instanceList != null) {
-
- for(RelatedInstanceList relatedInstanceList : instanceList){
-
- RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
- if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){
- aq.setVnfType(vnfType);
+ }else{
+ RequestInfo requestInfo =servInsReq.getRequestDetails().getRequestInfo();
+ if (requestInfo != null) {
+
+ if(requestInfo.getSource() != null){
+ aq.setSource(requestInfo.getSource());
+ }
+ if(requestInfo.getCallbackUrl() != null){
+ aq.setCallBackUrl(requestInfo.getCallbackUrl());
+ }
+ if(requestInfo.getCorrelator() != null){
+ aq.setCorrelator(requestInfo.getCorrelator());
+ }
+
+ if(requestInfo.getRequestorId() != null) {
+ aq.setRequestorId(requestInfo.getRequestorId());
+ }
+ }
+
+ if (servInsReq.getRequestDetails().getModelInfo() != null || (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig)) {
+ aq.setRequestScope(requestScope);
+ }
+
+ if (servInsReq.getRequestDetails().getCloudConfiguration() != null) {
+ CloudConfiguration cloudConfiguration = servInsReq.getRequestDetails().getCloudConfiguration();
+ if(cloudConfiguration.getLcpCloudRegionId() != null) {
+ aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId());
+ }
+
+ if(cloudConfiguration.getTenantId() != null) {
+ aq.setTenantId(cloudConfiguration.getTenantId());
+ }
+
+ }
+
+ if(servInsReq.getServiceInstanceId() != null){
+ aq.setServiceInstanceId(servInsReq.getServiceInstanceId());
+ }
+
+ if(servInsReq.getVnfInstanceId() != null){
+ aq.setVnfId(servInsReq.getVnfInstanceId());
+ }
+
+ if(ModelType.service.name().equalsIgnoreCase(requestScope)){
+ if(servInsReq.getRequestDetails().getRequestInfo().getInstanceName() != null){
+ aq.setServiceInstanceName(requestInfo.getInstanceName());
+ }
+ }
+
+ if(ModelType.network.name().equalsIgnoreCase(requestScope)){
+ aq.setNetworkName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
+ aq.setNetworkType(networkType);
+ aq.setNetworkId(servInsReq.getNetworkInstanceId());
+ }
+
+ if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)){
+ aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
+ aq.setVolumeGroupName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
+ aq.setVnfType(vnfType);
+
+ }
+
+ if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)){
+ aq.setVfModuleName(requestInfo.getInstanceName());
+ aq.setVfModuleModelName(servInsReq.getRequestDetails().getModelInfo().getModelName());
+ aq.setVfModuleId(servInsReq.getVfModuleInstanceId());
+ aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
+ aq.setVnfType(vnfType);
+
+ }
+
+ if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ aq.setConfigurationId(servInsReq.getConfigurationId());
+ aq.setConfigurationName(requestInfo.getInstanceName());
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.name())){
+ aq.setInstanceGroupId(servInsReq.getInstanceGroupId());
+ aq.setInstanceGroupName(requestInfo.getInstanceName());
+ }
+ if(ModelType.vnf.name().equalsIgnoreCase(requestScope)){
+ aq.setVnfName(requestInfo.getInstanceName());
+ if (null != servInsReq.getRequestDetails()) {
+ RelatedInstanceList[] instanceList = servInsReq.getRequestDetails().getRelatedInstanceList();
+
+ if (instanceList != null) {
+
+ for(RelatedInstanceList relatedInstanceList : instanceList){
+
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){
+ aq.setVnfType(vnfType);
+ }
}
}
}
- }
+ }
}
aq.setRequestBody (originalRequestJSON);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index cb66209fc9..0cd5d8dcb7 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -32,6 +32,7 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandler.camundabeans.CamundaResponse;
import org.onap.so.apihandler.common.CommonConstants;
import org.onap.so.apihandler.common.ErrorNumbers;
@@ -93,6 +94,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.net.URL;
@@ -611,12 +613,75 @@ public class ServiceInstances {
instanceIdMap.put("networkInstanceId", networkInstanceId);
return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
}
+
+ @POST
+ @Path("/{version:[vV][7]}/instanceGroups")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create instanceGroups",response=Response.class)
+ @Transactional
+ public Response createInstanceGroups(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ return serviceInstances(request, Action.createInstance, null, version, requestId, getRequestUri(requestContext));
+ }
+
+ @DELETE
+ @Path("/{version:[vV][7]}/instanceGroups/{instanceGroupId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete instanceGroup",response=Response.class)
+ @Transactional
+ public Response deleteInstanceGroups(@PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put(CommonConstants.INSTANCE_GROUP_ID, instanceGroupId);
+ return deleteInstanceGroups(Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext), requestContext);
+ }
+
+ @POST
+ @Path("/{version:[vV][7]}/instanceGroups/{instanceGroupId}/addMembers")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Add instanceGroup members",response=Response.class)
+ @Transactional
+ public Response addInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put(CommonConstants.INSTANCE_GROUP_ID, instanceGroupId);
+ return serviceInstances(request, Action.addMembers, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][7]}/instanceGroups/{instanceGroupId}/removeMembers")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Remove instanceGroup members",response=Response.class)
+ @Transactional
+ public Response removeInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put(CommonConstants.INSTANCE_GROUP_ID, instanceGroupId);
+ return serviceInstances(request, Action.removeMembers, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
public String getRequestUri(ContainerRequestContext context){
String requestUri = context.getUriInfo().getPath();
requestUri = requestUri.substring(requestUri.indexOf("/serviceInstantiation/") + 22);
return requestUri;
}
+
+ public void validateHeaders(ContainerRequestContext context) throws ValidationException{
+ MultivaluedMap<String, String> headers = context.getHeaders();
+ if(!headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID)){
+ throw new ValidationException(ONAPLogConstants.Headers.REQUEST_ID + " header", true);
+ }
+ if(!headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME)){
+ throw new ValidationException(ONAPLogConstants.Headers.PARTNER_NAME + " header", true);
+ }
+ if(!headers.containsKey(MsoLogger.REQUESTOR_ID)){
+ throw new ValidationException(MsoLogger.REQUESTOR_ID + " header", true);
+ }
+ }
public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException {
String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId");
@@ -624,7 +689,7 @@ public class ServiceInstances {
long startTime = System.currentTimeMillis ();
ServiceInstancesRequest sir = null;
String apiVersion = version.substring(1);
-
+
sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
String requestScope = deriveRequestScope(action, sir, requestUri);
InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.PENDING, requestJSON, requestScope);
@@ -672,6 +737,8 @@ public class ServiceInstances {
ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
modelType = ModelType.vnf;
+ }else if(action == Action.addMembers || action == Action.removeMembers){
+ modelType = ModelType.instanceGroup;
}else {
modelType =modelInfo.getModelType();
}
@@ -719,7 +786,7 @@ public class ServiceInstances {
String volumeGroupId = "";
String networkId = "";
String correlationId = "";
-
+ String instanceGroupId = null;
if(sir.getServiceInstanceId () != null){
serviceInstanceId = sir.getServiceInstanceId ();
}
@@ -739,6 +806,9 @@ public class ServiceInstances {
if(sir.getNetworkInstanceId () != null){
networkId = sir.getNetworkInstanceId ();
}
+ if(sir.getInstanceGroupId() != null){
+ instanceGroupId = sir.getInstanceGroupId();
+ }
correlationId = getCorrelationId(sir);
@@ -756,9 +826,93 @@ public class ServiceInstances {
aLaCarte = false;
}
- return postBPELRequest(currentActiveReq,action, requestId, startTime, requestJSON, recipeLookupResult.getOrchestrationURI(), recipeLookupResult.getRecipeTimeout(),
- isBaseVfModule, serviceInstanceId, correlationId, vnfId, vfModuleId, volumeGroupId, networkId, null,
- serviceInstanceType,vnfType, vfModuleType,networkType, apiVersion, aLaCarte, requestUri, null, requestScope, sir);
+ RequestClientParameter requestClientParameter = null;
+ try {
+ requestClientParameter = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(isBaseVfModule)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.toString())
+ .setServiceInstanceId(serviceInstanceId)
+ .setCorrelationId(correlationId)
+ .setVnfId(vnfId)
+ .setVfModuleId(vfModuleId)
+ .setVolumeGroupId(volumeGroupId)
+ .setNetworkId(networkId)
+ .setServiceType(serviceInstanceType)
+ .setVnfType(vnfType)
+ .setVfModuleType(vfModuleType)
+ .setNetworkType(networkType)
+ .setRequestDetails(mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
+ .setApiVersion(apiVersion)
+ .setALaCarte(aLaCarte)
+ .setRequestUri(requestUri)
+ .setInstanceGroupId(instanceGroupId).build();
+ } catch (IOException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+ }
+ return postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
+ }
+ public Response deleteInstanceGroups(Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri, ContainerRequestContext requestContext) throws ApiException {
+ String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_ID);
+ Boolean aLaCarte = true;
+ long startTime = System.currentTimeMillis ();
+ String apiVersion = version.substring(1);
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ sir.setInstanceGroupId(instanceGroupId);
+
+ String requestScope = ModelType.instanceGroup.toString();
+ InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.PENDING, null, requestScope);
+ setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+ try {
+ validateHeaders(requestContext);
+ } catch (ValidationException e) {
+ msoLogger.error(e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ throw validateException;
+ }
+
+ InfraActiveRequests dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq);
+
+ if (dup != null) {
+ buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup);
+ }
+
+ ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
+
+ RequestReferences referencesResponse = new RequestReferences();
+
+ referencesResponse.setRequestId(requestId);
+
+ serviceResponse.setRequestReferences(referencesResponse);
+ Boolean isBaseVfModule = false;
+
+ RecipeLookupResult recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
+
+ try{
+ infraActiveRequestsClient.save(currentActiveReq);
+ }catch(Exception e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ }
+
+ RequestClientParameter requestClientParameter = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(isBaseVfModule)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.toString())
+ .setApiVersion(apiVersion)
+ .setALaCarte(aLaCarte)
+ .setRequestUri(requestUri)
+ .setInstanceGroupId(instanceGroupId).build();
+
+ return postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
private String getCorrelationId(ServiceInstancesRequest sir) {
@@ -772,6 +926,8 @@ public class ServiceInstances {
private String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) {
if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){
return (ModelType.vnf.name());
+ }else if(action == Action.addMembers || action == Action.removeMembers){
+ return(ModelType.instanceGroup.toString());
}else{
String requestScope;
if(sir.getRequestDetails().getModelInfo().getModelType() == null){
@@ -799,38 +955,12 @@ public class ServiceInstances {
}
return requestScope;
}
- private Response postBPELRequest(InfraActiveRequests currentActiveReq, Actions action, String requestId, long startTime, String msoRawRequest,
- String orchestrationUri, int timeOut, Boolean isBaseVfModule,
- String serviceInstanceId, String correlationId, String vnfId, String vfModuleId, String volumeGroupId, String networkId,
- String configurationId, String serviceInstanceType, String vnfType, String vfModuleType, String networkType,
- String apiVersion, boolean aLaCarte, String requestUri, String paramXsd, String requestScope, ServiceInstancesRequest sir) throws ApiException {
+ private Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter, String orchestrationUri, String requestScope)throws ApiException {
RequestClient requestClient = null;
HttpResponse response = null;
try {
requestClient = reqClientFactory.getRequestClient (orchestrationUri);
- response = requestClient.post(new RequestClientParameter.Builder()
- .setRequestId(requestId)
- .setBaseVfModule(isBaseVfModule)
- .setRecipeTimeout(timeOut)
- .setRequestAction(action.toString())
- .setServiceInstanceId(serviceInstanceId)
- .setCorrelationId(correlationId)
- .setVnfId(vnfId)
- .setVfModuleId(vfModuleId)
- .setVolumeGroupId(volumeGroupId)
- .setNetworkId(networkId)
- .setConfigurationId(configurationId)
- .setServiceType(serviceInstanceType)
- .setVnfType(vnfType)
- .setVfModuleType(vfModuleType)
- .setNetworkType(networkType)
- .setRequestDetails(mapJSONtoMSOStyle(msoRawRequest, sir, aLaCarte, action))
- .setApiVersion(apiVersion)
- .setALaCarte(aLaCarte)
- .setRecipeParamXsd(paramXsd)
- .setRequestUri(requestUri).build());
-
-
+ response = requestClient.post(requestClientParameter);
} catch (Exception e) {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
@@ -874,8 +1004,8 @@ public class ServiceInstances {
try {
ObjectMapper mapper = new ObjectMapper();
jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class);
- jsonResponse.getRequestReferences().setRequestId(requestId);
- Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestId);
+ jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId());
+ Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestClientParameter.getRequestId());
if(selfLinkUrl.isPresent()){
jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get());
} else {
@@ -900,7 +1030,8 @@ public class ServiceInstances {
throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
.errorInfo(errorLoggerInfo).build();
}
- return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, jsonResponse, apiVersion);
+
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(), jsonResponse, requestClientParameter.getApiVersion());
}
}
@@ -943,6 +1074,8 @@ public class ServiceInstances {
currentActiveReq.setNetworkId(instanceId);
} else if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
currentActiveReq.setConfigurationId(instanceId);
+ }else if(ModelType.instanceGroup.toString().equalsIgnoreCase(requestScope)){
+ currentActiveReq.setInstanceGroupId(instanceId);
}
} else if(instanceIdMap != null && !instanceIdMap.isEmpty()) {
if(instanceIdMap.get("serviceInstanceId") != null){
@@ -963,21 +1096,27 @@ public class ServiceInstances {
if(instanceIdMap.get("configurationInstanceId") != null){
currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
}
+ if(instanceIdMap.get("InstanceGroupInstanceId") != null){
+ currentActiveReq.setInstanceGroupId(instanceIdMap.get("InstanceGroupInstanceId"));
+ }
}
}
protected String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest, boolean isAlaCarte, Actions action) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
- ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class);
- if( !isAlaCarte && Action.createInstance.equals(action) && serviceInstRequest != null &&
- serviceInstRequest.getRequestDetails() != null &&
- serviceInstRequest.getRequestDetails().getRequestParameters() != null) {
- sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
- sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
+ if(msoRawRequest != null){
+ ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class);
+ if( !isAlaCarte && Action.createInstance.equals(action) && serviceInstRequest != null &&
+ serviceInstRequest.getRequestDetails() != null &&
+ serviceInstRequest.getRequestDetails().getRequestParameters() != null) {
+ sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
+ sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
+ }
+ msoLogger.debug("Value as string: " + mapper.writeValueAsString(sir));
+ return mapper.writeValueAsString(sir);
}
- msoLogger.debug("Value as string: " + mapper.writeValueAsString(sir));
- return mapper.writeValueAsString(sir);
+ return null;
}
private void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, HashMap<String, String> instanceIdMap, long startTime, MsoRequest msoRequest,
@@ -1065,7 +1204,9 @@ public class ServiceInstances {
if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
recipeLookupResult = getDefaultVnfUri(sir, action);
- } else if (modelInfo.getModelType().equals(ModelType.service)) {
+ }else if(action == Action.addMembers || action == Action.removeMembers){
+ recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
+ }else if (modelInfo.getModelType().equals(ModelType.service)) {
try {
recipeLookupResult = getServiceURI(sir, action,alaCarteFlag);
} catch (IOException e) {
@@ -1107,7 +1248,9 @@ public class ServiceInstances {
updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
- }
+ }
+ }else if(modelInfo.getModelType().equals(ModelType.instanceGroup)){
+ recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
}
if (recipeLookupResult == null) {
@@ -1672,9 +1815,27 @@ public class ServiceInstances {
}else if(aLaCarte == null){
aLaCarte = false;
}
-
- return postBPELRequest(currentActiveReq,action, requestId, startTime, requestJSON, orchestrationUri, Integer.parseInt(timeOut), false,
- serviceInstanceId, correlationId, null, null, null, null, configurationId, null, null, null, null, apiVersion, aLaCarte, requestUri, null, requestScope, null);
+ RequestClientParameter requestClientParameter = null;
+ try {
+ requestClientParameter = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(false)
+ .setRecipeTimeout(Integer.parseInt(timeOut))
+ .setRequestAction(action.toString())
+ .setServiceInstanceId(serviceInstanceId)
+ .setCorrelationId(correlationId)
+ .setConfigurationId(configurationId)
+ .setRequestDetails(mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action))
+ .setApiVersion(apiVersion)
+ .setALaCarte(aLaCarte)
+ .setRequestUri(requestUri).build();
+ } catch (IOException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+ }
+
+ return postBPELRequest(currentActiveReq, requestClientParameter, orchestrationUri, requestScope);
}
public String getRequestId(ContainerRequestContext requestContext) throws ValidateException {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
index b0ea85779c..937ce19741 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
@@ -39,25 +39,26 @@ public class CloudConfigurationValidation implements ValidationRule{
Actions action = info.getAction();
Boolean aLaCarteFlag = info.getALaCarteFlag();
-
- if(cloudConfiguration == null && reqVersion >= 5 && (aLaCarteFlag != null && aLaCarteFlag)){
- if((!requestScope.equalsIgnoreCase(ModelType.service.name()) && !requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
- (action == Action.createInstance || action == Action.deleteInstance || action == Action.updateInstance)){
- throw new ValidationException ("cloudConfiguration");
- }
- if((requestScope.equalsIgnoreCase(ModelType.vnf.name()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name())) &&
- action == Action.replaceInstance){
- throw new ValidationException ("cloudConfiguration");
- }
- if(requestScope.equalsIgnoreCase(ModelType.configuration.name()) &&
- (action == Action.enablePort || action == Action.disablePort || action == Action.activateInstance || action == Action.deactivateInstance)){
- throw new ValidationException ("cloudConfiguration");
- }
- if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && (action == Action.deactivateAndCloudDelete || action == Action.scaleOut)){
- throw new ValidationException("cloudConfiguration");
- }
- if(requestScope.equals(ModelType.vnf.name()) && action == Action.recreateInstance){
- throw new ValidationException("cloudConfiguration", true);
+ if(!requestScope.equals(ModelType.instanceGroup.toString())){
+ if(cloudConfiguration == null && reqVersion >= 5 && (aLaCarteFlag != null && aLaCarteFlag)){
+ if((!requestScope.equalsIgnoreCase(ModelType.service.name()) && !requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
+ (action == Action.createInstance || action == Action.deleteInstance || action == Action.updateInstance)){
+ throw new ValidationException ("cloudConfiguration");
+ }
+ if((requestScope.equalsIgnoreCase(ModelType.vnf.name()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name())) &&
+ action == Action.replaceInstance){
+ throw new ValidationException ("cloudConfiguration");
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.configuration.name()) &&
+ (action == Action.enablePort || action == Action.disablePort || action == Action.activateInstance || action == Action.deactivateInstance)){
+ throw new ValidationException ("cloudConfiguration");
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && (action == Action.deactivateAndCloudDelete || action == Action.scaleOut)){
+ throw new ValidationException("cloudConfiguration");
+ }
+ if(requestScope.equals(ModelType.vnf.name()) && action == Action.recreateInstance){
+ throw new ValidationException("cloudConfiguration", true);
+ }
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
index a42a13c676..f1985e9fcf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
@@ -23,6 +23,7 @@ package org.onap.so.apihandlerinfra.validation;
import java.util.HashMap;
+import org.onap.so.apihandler.common.CommonConstants;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.utils.UUIDChecker;
@@ -75,6 +76,13 @@ public class InstanceIdMapValidation implements ValidationRule{
}
sir.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
}
+
+ if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_ID) != null){
+ if (!UUIDChecker.isValidUUID (instanceIdMap.get (CommonConstants.INSTANCE_GROUP_ID))) {
+ throw new ValidationException (CommonConstants.INSTANCE_GROUP_ID, true);
+ }
+ sir.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_ID));
+ }
}
return info;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java
new file mode 100644
index 0000000000..89bb15dcb1
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.apihandlerinfra.validation;
+
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+
+public class MembersValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo();
+ RelatedInstanceList[] relatedInstanceList = info.getSir().getRequestDetails().getRelatedInstanceList();
+ boolean vnfRelatedInstance = false;
+
+ if(requestInfo == null){
+ throw new ValidationException("requestInfo", true);
+ }else if(empty(requestInfo.getRequestorId())) {
+ throw new ValidationException ("requestorId", true);
+ }else if (empty (requestInfo.getSource ())) {
+ throw new ValidationException ("source", true);
+ }
+ if(relatedInstanceList == null){
+ throw new ValidationException("related instances", true);
+ }else{
+ for(RelatedInstanceList instanceList : relatedInstanceList){
+ RelatedInstance relatedInstance = instanceList.getRelatedInstance();
+ ModelType modelType = relatedInstance.getModelInfo().getModelType();
+ if(empty(relatedInstance.getInstanceId())){
+ throw new ValidationException("instanceId in relatedInstances", true);
+ }
+ if (modelType == null) {
+ throw new ValidationException("modelType in relatedInstance", true);
+ }
+ if(modelType == ModelType.vnf){
+ vnfRelatedInstance = true;
+ }
+ }
+ if(!vnfRelatedInstance){
+ throw new ValidationException("vnf relatedInstance", true);
+ }
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
index c6fae6e872..e2a1bdc46a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
@@ -30,9 +30,9 @@ import org.onap.so.serviceinstancebeans.ModelType;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.utils.UUIDChecker;
public class ModelInfoValidation implements ValidationRule{
- private static boolean empty(String s) {
- return (s == null || s.trim().isEmpty());
- }
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
@Override
public ValidationInformation validate(ValidationInformation info) throws ValidationException{
ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo();
@@ -42,89 +42,96 @@ public class ModelInfoValidation implements ValidationRule{
int reqVersion = info.getReqVersion();
Boolean aLaCarteFlag = info.getALaCarteFlag();
- if(!empty(modelInfo.getModelNameVersionId())){
- modelInfo.setModelVersionId(modelInfo.getModelNameVersionId());
- }
- // modelCustomizationId is required when usePreLoad is false for v4 and higher for VF Module Create
- if(requestParameters != null && reqVersion >= 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.createInstance && !requestParameters.isUsePreload()) {
- if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
- throw new ValidationException("modelCustomizationId");
- }
- }
-
- // modelCustomizationId is required for v5 and higher for VF Module Replace
- if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.replaceInstance) {
- if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
- throw new ValidationException("modelCustomizationId");
- }
- }
-
- // modelCustomizationId or modelCustomizationName are required for VNF Replace
- if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance || action == Action.recreateInstance) {
- if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) {
- throw new ValidationException("modelCustomizationId or modelCustomizationName");
- }
- }
+ if(!requestScope.equals(ModelType.instanceGroup.toString())){
+
+ if(!empty(modelInfo.getModelNameVersionId())){
+ modelInfo.setModelVersionId(modelInfo.getModelNameVersionId());
+ }
+ // modelCustomizationId is required when usePreLoad is false for v4 and higher for VF Module Create
+ if(requestParameters != null && reqVersion >= 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.createInstance && !requestParameters.isUsePreload()) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
+ throw new ValidationException("modelCustomizationId");
+ }
+ }
+
+ // modelCustomizationId is required for v5 and higher for VF Module Replace
+ if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.replaceInstance) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
+ throw new ValidationException("modelCustomizationId");
+ }
+ }
+
+ // modelCustomizationId or modelCustomizationName are required for VNF Replace
+ if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance || action == Action.recreateInstance) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) {
+ throw new ValidationException("modelCustomizationId or modelCustomizationName");
+ }
+ }
+
+ //is required for serviceInstance delete macro when aLaCarte=false (v3)
+ //create and updates except for network (except v4)
+ if (empty (modelInfo.getModelInvariantId ()) && ((reqVersion >2 && (aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
+ !(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ())) &&
+ (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
+ (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
+ throw new ValidationException ("modelInvariantId");
+ }
+ if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){
+ throw new ValidationException("modelInvariantId");
+ }
+ if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
+ throw new ValidationException("modelInvariantId", true);
+ }
+ if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) {
+ throw new ValidationException ("modelInvariantId format");
+ }
+
+ if(reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance ||
+ action == Action.addRelationships || action == Action.removeRelationships || action == Action.recreateInstance || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){
+ throw new ValidationException ("modelName", true);
+ }
- //is required for serviceInstance delete macro when aLaCarte=false (v3)
- //create and updates except for network (except v4)
- if (empty (modelInfo.getModelInvariantId ()) && ((reqVersion >2 && (aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
- !(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ())) &&
- (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
- (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
- throw new ValidationException ("modelInvariantId");
- }
- if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){
- throw new ValidationException("modelInvariantId");
- }
- if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
- throw new ValidationException("modelInvariantId", true);
- }
- if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) {
- throw new ValidationException ("modelInvariantId format");
- }
+ if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
+ (!(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ()))
+ && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships || action == Action.scaleOut))) {
+ throw new ValidationException ("modelVersion");
+ }
- if(reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance ||
- action == Action.addRelationships || action == Action.removeRelationships || action == Action.recreateInstance || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){
- throw new ValidationException ("modelName", true);
- }
+ if(empty(modelInfo.getModelVersion()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
+ throw new ValidationException("modelVersion", true);
+ }
- if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
- (!(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ()))
- && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships || action == Action.scaleOut))) {
- throw new ValidationException ("modelVersion");
- }
-
- if(empty(modelInfo.getModelVersion()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
- throw new ValidationException("modelVersion", true);
- }
+ // is required for serviceInstance delete macro when aLaCarte=false in v4
+ if (reqVersion >= 4 && empty (modelInfo.getModelVersionId()) && (((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
+ (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
+ (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
+ throw new ValidationException ("modelVersionId");
+ }
+ if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
+ throw new ValidationException("modelVersionId", true);
+ }
+ if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){
+ throw new ValidationException("modelVersionId");
+ }
- // is required for serviceInstance delete macro when aLaCarte=false in v4
- if (reqVersion >= 4 && empty (modelInfo.getModelVersionId()) && (((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
- (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
- (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
- throw new ValidationException ("modelVersionId");
- }
- if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){
- throw new ValidationException("modelVersionId", true);
- }
- if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){
- throw new ValidationException("modelVersionId");
- }
-
- if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) {
- if (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) {
- throw new ValidationException ("modelCustomizationId or modelCustomizationName");
- }
- }
+ if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) {
+ if (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) {
+ throw new ValidationException ("modelCustomizationId or modelCustomizationName");
+ }
+ }
- if(reqVersion >= 4 && (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) && (requestScope.equalsIgnoreCase (ModelType.network.name ()) || requestScope.equalsIgnoreCase(ModelType.configuration.name()))
- && (action == Action.updateInstance || action == Action.createInstance)){
- throw new ValidationException ("modelCustomizationId");
- }
- if(empty(modelInfo.getModelCustomizationId()) && action == Action.scaleOut && !(requestParameters.getTestApi() == TestApi.VNF_API.name() && requestParameters.isUsePreload() == true)){
- throw new ValidationException ("modelCustomizationId");
- }
- return info;
+ if(reqVersion >= 4 && (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) && (requestScope.equalsIgnoreCase (ModelType.network.name ()) || requestScope.equalsIgnoreCase(ModelType.configuration.name()))
+ && (action == Action.updateInstance || action == Action.createInstance)){
+ throw new ValidationException ("modelCustomizationId");
+ }
+ if(empty(modelInfo.getModelCustomizationId()) && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut && !(requestParameters.getTestApi() == TestApi.VNF_API.name() && requestParameters.isUsePreload() == true)){
+ throw new ValidationException ("modelCustomizationId");
+ }
+ }else{
+ if(empty(modelInfo.getModelVersionId()) && action == Action.createInstance){
+ throw new ValidationException("modelVersionId", true);
+ }
+ }
+ return info;
}
-} \ No newline at end of file
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
index f22294b33f..c4671aed3c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
@@ -100,9 +100,14 @@ public class RelatedInstancesValidation implements ValidationRule{
if (!empty(relatedInstance.getInstanceId ()) && !UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) {
throw new ValidationException ("instanceId format in relatedInstance");
}
-
-
- if (action != Action.deleteInstance) {
+ if(empty(relatedInstanceModelInfo.getModelVersionId()) && requestScope.equals(ModelType.instanceGroup.toString()) && relatedInstanceModelInfo.getModelType().equals(ModelType.service)){
+ throw new ValidationException("modelVersionId in relatedInstance", true);
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && relatedInstanceModelInfo.getModelType().equals(ModelType.service)){
+ isRelatedServiceInstancePresent = true;
+ }
+
+ if (action != Action.deleteInstance && !requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())) {
if(!( relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup) ||
relatedInstanceModelInfo.getModelType().equals(ModelType.connectionPoint) ||
relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) ||
@@ -144,7 +149,7 @@ public class RelatedInstancesValidation implements ValidationRule{
}
}
- if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
+ if(relatedInstanceModelInfo.getModelType().equals(ModelType.service) && !(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && action == Action.createInstance)) {
isRelatedServiceInstancePresent = true;
if (!relatedInstance.getInstanceId ().equals (sir.getServiceInstanceId ())) {
throw new ValidationException ("serviceInstanceId matching the serviceInstanceId in request URI");
@@ -177,7 +182,11 @@ public class RelatedInstancesValidation implements ValidationRule{
throw new ValidationException ("connectionPoint relatedInstance for Port Configuration");
}
}
-
+ if(requestScope.equals(ModelType.instanceGroup.toString())){
+ if(!isRelatedServiceInstancePresent){
+ throw new ValidationException("related service instance for instanceGroup request", true);
+ }
+ }
if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) {
if (!isRelatedServiceInstancePresent) {
throw new ValidationException ("related service instance for volumeGroup request");
@@ -223,6 +232,9 @@ public class RelatedInstancesValidation implements ValidationRule{
msoLogger.debug ("related instance exception");
throw new ValidationException ("related instances");
}
+ if(instanceList == null && requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && action == Action.createInstance){
+ throw new ValidationException("relatedInstanceList", true);
+ }
info.setVfModuleModelName(vfModuleModelName);
info.setServiceInstanceType(serviceInstanceType);
info.setVnfType(vnfType);