aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/nbi/apis/serviceorder/workflow
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/nbi/apis/serviceorder/workflow')
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIOwningEntityManager.java62
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/workflow/PostSoProcessor.java19
2 files changed, 70 insertions, 11 deletions
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIOwningEntityManager.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIOwningEntityManager.java
new file mode 100644
index 0000000..27cb6c8
--- /dev/null
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIOwningEntityManager.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2019 Orange
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ */
+package org.onap.nbi.apis.serviceorder.workflow;
+
+import org.onap.nbi.apis.serviceorder.MultiClient;
+import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
+import org.onap.nbi.apis.serviceorder.model.StateType;
+import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
+import org.onap.nbi.apis.serviceorder.service.ServiceOrderService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CreateAAIOwningEntityManager {
+
+
+ @Autowired
+ private MultiClient serviceOrderConsumerService;
+
+ @Autowired
+ ServiceOrderService serviceOrderService;
+
+ @Value("${so.owning.entity.id}")
+ private String owningEntityId;
+
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CreateAAIOwningEntityManager.class);
+
+
+ public void createAAIOwningEntity(ServiceOrder serviceOrder,
+ ServiceOrderInfo serviceOrderInfo) {
+
+ String owningEntityIdToSo=serviceOrderConsumerService.getOwningEntityIdInAAI(serviceOrder);
+ if (owningEntityIdToSo==null) {
+ owningEntityIdToSo=owningEntityId;
+ boolean owningEntity = serviceOrderConsumerService.putOwningEntity(serviceOrder);
+ if (!owningEntity) {
+ serviceOrderService.updateOrderState(serviceOrder, StateType.REJECTED);
+ LOGGER.warn("serviceOrder {} rejected : cannot create owning entity ", serviceOrder.getId());
+ serviceOrderService.addOrderMessage(serviceOrder, "501");
+ }
+ }
+ serviceOrderInfo.setOwningEntityId(owningEntityIdToSo);
+ }
+
+
+}
+
+
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 deb4e55..7fdcdaa 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
@@ -117,10 +117,7 @@ public class PostSoProcessor {
private ResponseEntity<CreateServiceInstanceResponse> postSORequest(
ServiceOrderItem serviceOrderItem, ServiceOrderInfo serviceOrderInfo) {
RequestDetails requestDetails =
- buildSoRequest(
- serviceOrderItem, serviceOrderInfo.getServiceOrderItemInfos()
- .get(serviceOrderItem.getId()).getCatalogResponse(),
- serviceOrderInfo.getSubscriberInfo());
+ buildSoRequest(serviceOrderItem,serviceOrderInfo);
MSOPayload msoPayload = new MSOPayload(requestDetails);
ResponseEntity<CreateServiceInstanceResponse> response = null;
@@ -186,16 +183,15 @@ public class PostSoProcessor {
* Build SO CREATE request from the ServiceOrder and catalog informations from SDC
*
* @param orderItem
- * @param sdcInfos
- * @param subscriberInfo
+ * @param serviceOrderInfo
* @return
*/
- private RequestDetails buildSoRequest(ServiceOrderItem orderItem, Map<String, Object> sdcInfos,
- SubscriberInfo subscriberInfo) {
+ private RequestDetails buildSoRequest(ServiceOrderItem orderItem,ServiceOrderInfo serviceOrderInfo) {
RequestDetails requestDetails = new RequestDetails();
- requestDetails.setSubscriberInfo(subscriberInfo);
-
+ requestDetails.setSubscriberInfo( serviceOrderInfo.getSubscriberInfo());
+ Map<String, Object> sdcInfos=serviceOrderInfo.getServiceOrderItemInfos()
+ .get(orderItem.getId()).getCatalogResponse();
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelType("service");
modelInfo.setModelInvariantId((String) sdcInfos.get("invariantUUID"));
@@ -217,13 +213,14 @@ public class PostSoProcessor {
requestParameters.setUserParams(retrieveUserParamsFromServiceCharacteristics(
orderItem.getService().getServiceCharacteristic()));
requestParameters.setaLaCarte(true);
+ requestParameters.setTestApi("GR_API");
requestDetails.setRequestParameters(requestParameters);
CloudConfiguration cloudConfiguration = new CloudConfiguration(lcpCloudRegionId, tenantId, cloudOwner);
requestDetails.setCloudConfiguration(cloudConfiguration);
OwningEntity owningEntity = new OwningEntity();
- owningEntity.setOwningEntityId(soOwningEntityId);
+ owningEntity.setOwningEntityId(serviceOrderInfo.getOwningEntityId());
owningEntity.setOwningEntityName(soOwningEntityName);
requestDetails.setOwningEntity(owningEntity);