diff options
author | Priyadharshini <priyadharshini.b96@wipro.com> | 2020-02-04 12:38:29 +0000 |
---|---|---|
committer | Priyadharshini <priyadharshini.b96@wipro.com> | 2020-02-04 12:58:48 +0000 |
commit | 20e1c506b4157bd90189b24d4f4a33c61db6edfc (patch) | |
tree | ae9ecd00ef8c09dabf962f371a6973ec987ede8d /src/main/java | |
parent | 9cf4619264313d55bf02a0d30a40e20ac83f553c (diff) |
Implement serviceType handling for E2E network slicing
Issue-ID: EXTAPI-380
Signed-off-by: Priyadharshini <priyadharshini.b96@wipro.com>
Change-Id: Ib4cc70fd1b7a43b9bfe4a73659af5cc6f1b2f972
Diffstat (limited to 'src/main/java')
4 files changed, 28 insertions, 12 deletions
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/Service.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/Service.java index 6ecb77a..31802f2 100755 --- a/src/main/java/org/onap/nbi/apis/serviceorder/model/Service.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/model/Service.java @@ -57,6 +57,9 @@ import java.util.Objects; public class Service { @JsonProperty("id") private String id = null; + + @JsonProperty("serviceType") + private String servicetype = null; @JsonProperty("href") private String href = null; @@ -104,6 +107,16 @@ public class Service { public void setId(String id) { this.id = id; } + + @JsonProperty("serviceType") + @ApiModelProperty(value = "Business type of the service") + public String getServicetype() { + return servicetype; + } + + public void setServicetype(String servicetype) { + this.servicetype = servicetype; + } public Service href(String href) { this.href = href; diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/utils/E2EServiceUtils.java b/src/main/java/org/onap/nbi/apis/serviceorder/utils/E2EServiceUtils.java index f675428..086cd40 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/utils/E2EServiceUtils.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/utils/E2EServiceUtils.java @@ -18,6 +18,7 @@ import java.util.Map; import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderItemInfo; public class E2EServiceUtils { + public static boolean isE2EService(ServiceOrderItemInfo serviceOrderItemInfo) { Map<String, Object> sdcInfos = serviceOrderItemInfo.getCatalogResponse(); boolean e2eService = false; @@ -27,7 +28,7 @@ public class E2EServiceUtils { // and e2eServiceInstances )APIs for service CRUD // All E2E Services are required to be created in SDC under category "E2E Services" until SO fixes the // multiple API issue. - if (category.startsWith("e2e")) { + if (category.startsWith("e2e") || category.startsWith("CST")) { e2eService = true; } } diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIServiceTypeManager.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIServiceTypeManager.java index a8e4047..9cadb1e 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIServiceTypeManager.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIServiceTypeManager.java @@ -42,7 +42,6 @@ public class CreateAAIServiceTypeManager { private static final Logger LOGGER = LoggerFactory.getLogger(CreateAAIServiceTypeManager.class); public void createAAIServiceType(ServiceOrder serviceOrder, ServiceOrderInfo serviceOrderInfo) { - Map servicesInAaiForCustomer = serviceOrderConsumerService.getServicesInAaiForCustomer( serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId(), serviceOrder); @@ -50,14 +49,15 @@ public class CreateAAIServiceTypeManager { if (ActionType.ADD == serviceOrderItem.getAction()) { ServiceOrderItemInfo serviceOrderItemInfo = serviceOrderInfo.getServiceOrderItemInfos().get(serviceOrderItem.getId()); - String sdcServiceName = (String) serviceOrderItemInfo.getCatalogResponse().get("name"); - if (!serviceNameExistsInAAI(servicesInAaiForCustomer, sdcServiceName)) { + String serviceTypeFromJson = serviceOrderItem.getService().getServicetype(); + String serviceType = serviceTypeFromJson != null ? serviceTypeFromJson : (String) serviceOrderItemInfo.getCatalogResponse().get("name"); + if (!serviceNameExistsInAAI(servicesInAaiForCustomer, serviceType)) { boolean serviceCreated = serviceOrderConsumerService.putServiceType( - serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId(), sdcServiceName, serviceOrder); + serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId(), serviceType, serviceOrder); if (!serviceCreated) { serviceOrderService.updateOrderState(serviceOrder, StateType.REJECTED); LOGGER.warn("serviceOrder {} rejected : cannot create service type {} for customer {}", - serviceOrder.getId(), sdcServiceName, + serviceOrder.getId(), serviceType, serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId()); serviceOrderService.addOrderMessage(serviceOrder, "501"); @@ -68,14 +68,14 @@ public class CreateAAIServiceTypeManager { } - private boolean serviceNameExistsInAAI(Map servicesInAaiForCustomer, String sdcServiceName) { + private boolean serviceNameExistsInAAI(Map servicesInAaiForCustomer, String serviceType) { if (servicesInAaiForCustomer != null && servicesInAaiForCustomer.get("service-subscription") != null) { List<LinkedHashMap> servicesInAAI = (List<LinkedHashMap>) servicesInAaiForCustomer.get("service-subscription"); for (LinkedHashMap service : servicesInAAI) { - String serviceType = (String) service.get("service-type"); - if (sdcServiceName.equalsIgnoreCase(serviceType)) { + String serviceTypeInAAI = (String) service.get("service-type"); + if (serviceType.equalsIgnoreCase(serviceTypeInAAI)) { return true; } diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/PostSoProcessor.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/PostSoProcessor.java index 5694cfe..1b0d77f 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/PostSoProcessor.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/PostSoProcessor.java @@ -195,7 +195,9 @@ public class PostSoProcessor { requestDetails.setRequestInfo(requestInfo); RequestParameters requestParameters = new RequestParameters(); - requestParameters.setSubscriptionServiceType((String) sdcInfos.get("name")); + + String serviceTypeFromJson = orderItem.getService().getServicetype(); + requestParameters.setSubscriptionServiceType(serviceTypeFromJson != null ? serviceTypeFromJson:(String) sdcInfos.get("name")); requestParameters.setUserParams( retrieveUserParamsFromServiceCharacteristics(orderItem.getService().getServiceCharacteristic())); requestParameters.setaLaCarte(true); @@ -237,8 +239,8 @@ public class PostSoProcessor { service.setServiceUuid(serviceOrderItem.getService().getServiceSpecification().getId()); service.setServiceInvariantUuid((String) sdcInfos.get("invariantUUID")); service.setGlobalSubscriberId(subscriberInfo.getGlobalSubscriberId()); - service.setServiceType((String) sdcInfos.get("name")); - + String serviceTypeFromJson = serviceOrderItem.getService().getServicetype(); + service.setServiceType(serviceTypeFromJson != null ? serviceTypeFromJson : (String) sdcInfos.get("name")); ParametersModel parameters = new ParametersModel(); ArrayList<ResourceModel> resources = new ArrayList(); |