diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-03-10 10:56:41 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-03-12 09:54:12 -0400 |
commit | f99e4a56e6b9ec09ece48a7b111c9ec286220264 (patch) | |
tree | aa6b58ca16295b592cb4343da52c3ac6465a0351 /mso-api-handlers/mso-api-handler-infra/src/main/java/org | |
parent | 308c3c2085864e04848e53a589773ff2e6e2c76a (diff) |
add instance group support to SO
add create support
add delete support
added naming service support
Change-Id: Iaf4f2bdae8ea55aca71d6e9b818a76e90db0b012
Issue-ID: SO-1616
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org')
2 files changed, 27 insertions, 14 deletions
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 0b2b1e73b4..2dab494b07 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 @@ -657,7 +657,7 @@ public class ServiceInstances { 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); + instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId); return deleteInstanceGroups(Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext), requestContext); } @@ -670,7 +670,7 @@ public class ServiceInstances { 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); + instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId); return serviceInstances(request, Action.addMembers, instanceIdMap, version, requestId, getRequestUri(requestContext)); } @@ -683,7 +683,7 @@ public class ServiceInstances { 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); + instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId); return serviceInstances(request, Action.removeMembers, instanceIdMap, version, requestId, getRequestUri(requestContext)); } @@ -808,16 +808,13 @@ public class ServiceInstances { } - serviceInstanceId = ""; + serviceInstanceId = setServiceInstanceId(requestScope, sir); String vnfId = ""; String vfModuleId = ""; String volumeGroupId = ""; String networkId = ""; String pnfCorrelationId = ""; String instanceGroupId = null; - if(sir.getServiceInstanceId () != null){ - serviceInstanceId = sir.getServiceInstanceId (); - } if(sir.getVnfInstanceId () != null){ vnfId = sir.getVnfInstanceId (); @@ -884,7 +881,7 @@ public class ServiceInstances { 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); + String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID); Boolean aLaCarte = true; long startTime = System.currentTimeMillis (); String apiVersion = version.substring(1); @@ -1117,8 +1114,8 @@ public class ServiceInstances { if(instanceIdMap.get("configurationInstanceId") != null){ currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId")); } - if(instanceIdMap.get("InstanceGroupInstanceId") != null){ - currentActiveReq.setInstanceGroupId(instanceIdMap.get("InstanceGroupInstanceId")); + if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null){ + currentActiveReq.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID)); } } } @@ -1970,4 +1967,20 @@ public class ServiceInstances { } return serviceType; } + protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir){ + if(sir.getServiceInstanceId () != null){ + return sir.getServiceInstanceId (); + }else if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())){ + RelatedInstanceList[] relatedInstances = sir.getRequestDetails().getRelatedInstanceList(); + if(relatedInstances != null){ + for(RelatedInstanceList relatedInstanceList : relatedInstances){ + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + if(relatedInstance.getModelInfo().getModelType() == ModelType.service){ + return relatedInstance.getInstanceId(); + } + } + } + } + return null; + } } 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 f1985e9fcf..fad11a5cc6 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 @@ -77,11 +77,11 @@ 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); + if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null){ + if (!UUIDChecker.isValidUUID (instanceIdMap.get (CommonConstants.INSTANCE_GROUP_INSTANCE_ID))) { + throw new ValidationException (CommonConstants.INSTANCE_GROUP_INSTANCE_ID, true); } - sir.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_ID)); + sir.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID)); } } return info; |