summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap')
-rw-r--r--src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java2
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java2
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java22
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/ServiceOrderResource.java18
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ExecutionTask.java39
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderInfo.java13
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderInfoJson.java58
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/repositories/ServiceOrderInfoRepository.java24
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/workflow/CheckOrderConsistenceManager.java175
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAICustomerManager.java42
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIServiceTypeManager.java42
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java24
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java121
13 files changed, 301 insertions, 281 deletions
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java b/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java
index fed9bb5..e190cf0 100644
--- a/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java
+++ b/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java
@@ -140,7 +140,7 @@ public class SdcClient {
restTemplate.exchange(callURI, HttpMethod.GET, buildRequestHeader(), byte[].class);
LOGGER.info("response status : " + response.getStatusCodeValue());
if (!response.getStatusCode().equals(HttpStatus.OK)) {
- LOGGER.warn(HTTP_CALL_SDC_ON + callURI.toString() + " returns " + response.getStatusCodeValue() + ", "
+ LOGGER.error(HTTP_CALL_SDC_ON + callURI.toString() + " returns " + response.getStatusCodeValue() + ", "
+ response.getBody().toString());
}
return response;
diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java
index c973f32..33baa5b 100644
--- a/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java
+++ b/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java
@@ -39,7 +39,7 @@ public abstract class BaseClient {
LOGGER.debug("response body : " + response.getBody().toString());
LOGGER.info("response status : " + response.getStatusCodeValue());
if (!response.getStatusCode().equals(HttpStatus.OK)) {
- LOGGER.warn("HTTP call on " + callURL + " returns " + response.getStatusCodeValue() + ", "
+ LOGGER.error("HTTP call on " + callURL + " returns " + response.getStatusCodeValue() + ", "
+ response.getBody().toString());
}
return response;
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java b/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java
index 8c0b2be..27fec00 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java
@@ -130,7 +130,7 @@ public class MultiClient {
}
- public void putCustomer(SubscriberInfo subscriberInfo) {
+ public boolean putCustomer(SubscriberInfo subscriberInfo) {
Map<String, String> param = new HashMap<>();
param.put("global-customer-id", subscriberInfo.getGlobalSubscriberId());
param.put("subscriber-name", subscriberInfo.getSubscriberName());
@@ -138,7 +138,11 @@ public class MultiClient {
String callURL =
aaiHost + OnapComponentsUrlPaths.AAI_GET_CUSTOMER_PATH + subscriberInfo.getGlobalSubscriberId();
- putRequest(param, callURL, buildRequestHeaderForAAI());
+ ResponseEntity<Object> response = putRequest(param, callURL, buildRequestHeaderForAAI());
+ if (response != null && response.getStatusCode().equals(HttpStatus.CREATED)) {
+ return true;
+ }
+ return false;
}
@@ -154,16 +158,20 @@ public class MultiClient {
return null;
}
- public void putServiceType(String globalSubscriberId, String serviceName) {
+ public boolean putServiceType(String globalSubscriberId, String serviceName) {
Map<String, String> param = new HashMap<>();
param.put("service-type", serviceName);
String callURL = aaiHost + OnapComponentsUrlPaths.AAI_PUT_SERVICE_FOR_CUSTOMER_PATH + serviceName;
String callUrlFormated = callURL.toString().replace("$customerId", globalSubscriberId);
- putRequest(param, callUrlFormated, buildRequestHeaderForAAI());
+ ResponseEntity<Object> response = putRequest(param, callUrlFormated, buildRequestHeaderForAAI());
+ if (response != null && response.getStatusCode().equals(HttpStatus.CREATED)) {
+ return true;
+ }
+ return false;
}
- private void putRequest(Map<String, String> param, String callUrl, HttpHeaders httpHeaders) {
+ private ResponseEntity<Object> putRequest(Map<String, String> param, String callUrl, HttpHeaders httpHeaders) {
try {
ResponseEntity<Object> response =
restTemplate.exchange(callUrl, HttpMethod.PUT, new HttpEntity<>(param, httpHeaders), Object.class);
@@ -172,8 +180,10 @@ public class MultiClient {
LOGGER.warn("HTTP call on " + callUrl + " returns " + response.getStatusCodeValue() + ", "
+ response.getBody().toString());
}
+ return response;
} catch (BackendFunctionalException e) {
LOGGER.error("error on calling " + callUrl + " ," + e);
+ return null;
}
}
@@ -196,7 +206,7 @@ public class MultiClient {
LOGGER.debug("response body : " + response.getBody().toString());
LOGGER.info("response status : " + response.getStatusCodeValue());
if (!response.getStatusCode().equals(HttpStatus.OK)) {
- LOGGER.warn("HTTP call on " + callURL + " returns " + response.getStatusCodeValue() + ", "
+ LOGGER.error("HTTP call on " + callURL + " returns " + response.getStatusCodeValue() + ", "
+ response.getBody().toString());
}
return response;
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/ServiceOrderResource.java b/src/main/java/org/onap/nbi/apis/serviceorder/ServiceOrderResource.java
index 4530528..04a8329 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/ServiceOrderResource.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/ServiceOrderResource.java
@@ -22,7 +22,6 @@ import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
import org.onap.nbi.apis.serviceorder.model.StateType;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
-import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderInfoRepository;
import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderRepository;
import org.onap.nbi.apis.serviceorder.workflow.CheckOrderConsistenceManager;
import org.onap.nbi.apis.serviceorder.workflow.CreateAAICustomerManager;
@@ -74,9 +73,6 @@ public class ServiceOrderResource extends ResourceManagement<ServiceOrder> {
SOTaskManager serviceOrchestratorManager;
@Autowired
- ServiceOrderInfoRepository serviceOrderInfoRepository;
-
- @Autowired
MultiCriteriaRequestBuilder multiCriteriaRequestBuilder;
@@ -104,8 +100,7 @@ public class ServiceOrderResource extends ResourceManagement<ServiceOrder> {
headers.add("X-Total-Count", String.valueOf(totalCount));
headers.add("X-Result-Count", String.valueOf(serviceOrders.size()));
- ResponseEntity<Object> response = this.findResponse(serviceOrders, filter, headers);
- return response;
+ return this.findResponse(serviceOrders, filter, headers);
}
@@ -152,9 +147,14 @@ public class ServiceOrderResource extends ResourceManagement<ServiceOrder> {
changeServiceOrderState(serviceOrder, StateType.COMPLETED);
} else {
serviceOrderRepository.save(serviceOrder);
- createAAICustomer.createAAICustomer(serviceOrderInfo);
- createAAIServiceType.createAAIServiceType(serviceOrder, serviceOrderInfo);
- serviceOrchestratorManager.registerServiceOrder(serviceOrder, serviceOrderInfo);
+ createAAICustomer.createAAICustomer(serviceOrder,serviceOrderInfo);
+ if(StateType.ACKNOWLEDGED==serviceOrder.getState()) {
+ createAAIServiceType.createAAIServiceType(serviceOrder, serviceOrderInfo);
+ if(StateType.ACKNOWLEDGED==serviceOrder.getState()) {
+ serviceOrchestratorManager.registerServiceOrder(serviceOrder, serviceOrderInfo);
+ }
+ }
+
}
}
}
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ExecutionTask.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ExecutionTask.java
index 1aeab20..9fd0505 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ExecutionTask.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ExecutionTask.java
@@ -1,17 +1,14 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * 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
+ * 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
+ * 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.
+ * 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.model.orchestrator;
@@ -21,7 +18,7 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.OneToOne;
+import javax.persistence.Lob;
@Entity
public class ExecutionTask {
@@ -39,14 +36,14 @@ public class ExecutionTask {
private Date lastAttemptDate;
- @OneToOne
- private ServiceOrderInfoJson serviceOrderInfoJson;
+ @Lob
+ private String serviceOrderInfoJson;
- public ServiceOrderInfoJson getServiceOrderInfoJson() {
+ public String getServiceOrderInfoJson() {
return serviceOrderInfoJson;
}
- public void setServiceOrderInfoJson(ServiceOrderInfoJson serviceOrderInfoJson) {
+ public void setServiceOrderInfoJson(String serviceOrderInfoJson) {
this.serviceOrderInfoJson = serviceOrderInfoJson;
}
@@ -93,15 +90,17 @@ public class ExecutionTask {
@Override
public boolean equals(Object o) {
- if (this == o)
+ if (this == o) {
return true;
- if (o == null || getClass() != o.getClass())
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
+ }
ExecutionTask that = (ExecutionTask) o;
return nbRetries == that.nbRetries && Objects.equals(internalId, that.internalId)
- && Objects.equals(orderItemId, that.orderItemId) && Objects.equals(reliedTasks, that.reliedTasks)
- && Objects.equals(lastAttemptDate, that.lastAttemptDate)
- && Objects.equals(serviceOrderInfoJson, that.serviceOrderInfoJson);
+ && Objects.equals(orderItemId, that.orderItemId) && Objects.equals(reliedTasks, that.reliedTasks)
+ && Objects.equals(lastAttemptDate, that.lastAttemptDate)
+ && Objects.equals(serviceOrderInfoJson, that.serviceOrderInfoJson);
}
@Override
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderInfo.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderInfo.java
index b873cdc..fd0eed5 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderInfo.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderInfo.java
@@ -25,9 +25,18 @@ public class ServiceOrderInfo {
private boolean useServiceOrderCustomer;
private SubscriberInfo subscriberInfo;
private Map<String, ServiceOrderItemInfo> serviceOrderItemInfos = new HashMap<>();
- private boolean allItemsInAdd;
+ private boolean allItemsInAdd= true;
private boolean allItemsCompleted;
- private boolean serviceOrderRejected;
+ private boolean serviceOrderRejected= false;
+ private String serviceOrderId;
+
+ public String getServiceOrderId() {
+ return serviceOrderId;
+ }
+
+ public void setServiceOrderId(String serviceOrderId) {
+ this.serviceOrderId = serviceOrderId;
+ }
public boolean isAllItemsInAdd() {
return allItemsInAdd;
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderInfoJson.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderInfoJson.java
deleted file mode 100644
index cb22040..0000000
--- a/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderInfoJson.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright (c) 2018 Orange
- *
- * 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.
- */
-package org.onap.nbi.apis.serviceorder.model.orchestrator;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-
-@Entity
-public class ServiceOrderInfoJson {
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private Long internalId;
-
- private String serviceOrderId;
-
- @Lob
- private String serviceOrderInfoJson;
-
- public ServiceOrderInfoJson() {}
-
- public ServiceOrderInfoJson(String serviceOrderId, String serviceOrderInfoJson) {
- this.serviceOrderId = serviceOrderId;
- this.serviceOrderInfoJson = serviceOrderInfoJson;
- }
-
- public String getServiceOrderId() {
- return serviceOrderId;
- }
-
- public void setServiceOrderId(String serviceOrderId) {
- this.serviceOrderId = serviceOrderId;
- }
-
- public String getServiceOrderInfoJson() {
- return serviceOrderInfoJson;
- }
-
- public void setServiceOrderInfoJson(String serviceOrderInfoJson) {
- this.serviceOrderInfoJson = serviceOrderInfoJson;
- }
-}
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/repositories/ServiceOrderInfoRepository.java b/src/main/java/org/onap/nbi/apis/serviceorder/repositories/ServiceOrderInfoRepository.java
deleted file mode 100644
index f3eca16..0000000
--- a/src/main/java/org/onap/nbi/apis/serviceorder/repositories/ServiceOrderInfoRepository.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Copyright (c) 2018 Orange
- *
- * 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.
- */
-package org.onap.nbi.apis.serviceorder.repositories;
-
-
-import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfoJson;
-import org.springframework.data.repository.CrudRepository;
-
-public interface ServiceOrderInfoRepository extends CrudRepository<ServiceOrderInfoJson, String> {
-
-}
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CheckOrderConsistenceManager.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CheckOrderConsistenceManager.java
index 470b161..b3179c5 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CheckOrderConsistenceManager.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CheckOrderConsistenceManager.java
@@ -1,20 +1,14 @@
/**
- * Copyright (c) 2018 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.
+ * Copyright (c) 2018 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 java.util.LinkedHashMap;
import org.onap.nbi.apis.serviceorder.MultiClient;
import org.onap.nbi.apis.serviceorder.model.RelatedParty;
import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
@@ -23,14 +17,14 @@ import org.onap.nbi.apis.serviceorder.model.StateType;
import org.onap.nbi.apis.serviceorder.model.consumer.SubscriberInfo;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderItemInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
-import java.util.LinkedHashMap;
-
@Service
public class CheckOrderConsistenceManager {
@@ -38,59 +32,115 @@ public class CheckOrderConsistenceManager {
@Autowired
private MultiClient serviceOrderConsumerService;
+ private static final Logger LOGGER = LoggerFactory.getLogger(CheckOrderConsistenceManager.class);
+
public ServiceOrderInfo checkServiceOrder(ServiceOrder serviceOrder) {
ServiceOrderInfo serviceOrderInfo = new ServiceOrderInfo();
+ serviceOrderInfo.setServiceOrderId(serviceOrder.getId());
manageCustomer(serviceOrder, serviceOrderInfo);
int nbItemsCompleted = 0;
- boolean isServiceOrderRejected = false;
- boolean isAllItemsInAdd = true;
for (ServiceOrderItem serviceOrderItem : serviceOrder.getOrderItem()) {
ServiceOrderItemInfo serviceOrderItemInfo = new ServiceOrderItemInfo();
- serviceOrderItemInfo.setId(serviceOrderItem.getId());
handleServiceFromCatalog(serviceOrderItem, serviceOrderItemInfo);
- switch (serviceOrderItem.getAction()) {
- case ADD:
- if (existServiceInCatalog(serviceOrderItemInfo)
- && StringUtils.isEmpty(serviceOrderItem.getService().getId())
- && serviceOrderConsumerService.isTenantIdPresentInAAI()) {
- serviceOrderInfo.addServiceOrderItemInfos(serviceOrderItem.getId(), serviceOrderItemInfo);
- } else {
- isServiceOrderRejected = true;
- serviceOrderItem.setState(StateType.REJECTED);
- }
- break;
- case MODIFY:
- case DELETE:
- isAllItemsInAdd = false;
- if (isCustomerFromServiceOrderPresentInInventory(serviceOrderInfo)
- && existServiceInInventory(serviceOrderItem, serviceOrderItemInfo,
- serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId())) {
- serviceOrderInfo.addServiceOrderItemInfos(serviceOrderItem.getId(), serviceOrderItemInfo);
- } else {
- isServiceOrderRejected = true;
- serviceOrderItem.setState(StateType.REJECTED);
- }
- break;
- case NOCHANGE:
- isAllItemsInAdd = false;
- serviceOrderItem.setState(StateType.COMPLETED);
- nbItemsCompleted++;
- break;
+ if (!existServiceInCatalog(serviceOrderItemInfo)) {
+ serviceOrderInfo.setIsServiceOrderRejected(true);
+ serviceOrderItem.setState(StateType.REJECTED);
+ LOGGER.error(
+ "service order item {0} of service order {1} rejected cause no service catalog found for id {2}",
+ serviceOrderItem.getId(), serviceOrder.getId(),
+ serviceOrderItem.getService().getServiceSpecification().getId());
+ } else {
+ switch (serviceOrderItem.getAction()) {
+ case ADD:
+ handleServiceOrderItemInAdd(serviceOrderInfo, serviceOrderItem, serviceOrderItemInfo);
+ break;
+ case MODIFY:
+ case DELETE:
+ handleServiceOrderItemInChange(serviceOrderInfo, serviceOrderItem, serviceOrderItemInfo);
+ break;
+ case NOCHANGE:
+ serviceOrderInfo.setAllItemsInAdd(false);
+ serviceOrderItem.setState(StateType.COMPLETED);
+ nbItemsCompleted++;
+ break;
+ }
}
+
}
+
if (serviceOrder.getOrderItem().size() != nbItemsCompleted) {
serviceOrderInfo.setAllItemsCompleted(false);
} else {
serviceOrderInfo.setAllItemsCompleted(true);
}
- serviceOrderInfo.setAllItemsInAdd(isAllItemsInAdd);
- serviceOrderInfo.setIsServiceOrderRejected(isServiceOrderRejected);
return serviceOrderInfo;
}
+ private void handleServiceOrderItemInChange(ServiceOrderInfo serviceOrderInfo, ServiceOrderItem serviceOrderItem,
+ ServiceOrderItemInfo serviceOrderItemInfo) {
+ serviceOrderInfo.setAllItemsInAdd(false);
+ if (shouldAcceptServiceOrderItemToChange(serviceOrderInfo, serviceOrderItem,
+ serviceOrderItemInfo)) {
+ serviceOrderInfo.addServiceOrderItemInfos(serviceOrderItem.getId(), serviceOrderItemInfo);
+ } else {
+ serviceOrderInfo.setIsServiceOrderRejected(true);
+ serviceOrderItem.setState(StateType.REJECTED);
+ }
+ }
+
+ private void handleServiceOrderItemInAdd(ServiceOrderInfo serviceOrderInfo, ServiceOrderItem serviceOrderItem,
+ ServiceOrderItemInfo serviceOrderItemInfo) {
+ if (shouldAcceptServiceOrderItemToAdd(serviceOrderItem, serviceOrderInfo.getServiceOrderId())) {
+ serviceOrderInfo.addServiceOrderItemInfos(serviceOrderItem.getId(), serviceOrderItemInfo);
+ } else {
+ serviceOrderInfo.setIsServiceOrderRejected(true);
+ serviceOrderItem.setState(StateType.REJECTED);
+ }
+ }
+
+ private boolean shouldAcceptServiceOrderItemToAdd(ServiceOrderItem serviceOrderItem,
+ String serviceOrderId) {
+ if (!StringUtils.isEmpty(serviceOrderItem.getService().getId())) {
+ LOGGER
+ .error("serviceOrderItem {0} for serviceorder {1} rejected cause service.id must be empty in add action",
+ serviceOrderItem.getId(), serviceOrderId);
+ return false;
+ } else if (!serviceOrderConsumerService.isTenantIdPresentInAAI()) {
+ LOGGER.error("serviceOrderItem {0} for serviceOrder {1} rejected cause tenantId not found in AAI",
+ serviceOrderItem.getId(), serviceOrderId);
+ return false;
+ }
+ return true;
+ }
+
+ private boolean shouldAcceptServiceOrderItemToChange(ServiceOrderInfo serviceOrderInfo,
+ ServiceOrderItem serviceOrderItem,
+ ServiceOrderItemInfo serviceOrderItemInfo) {
+
+ if (StringUtils.isEmpty(serviceOrderItem.getService().getId())) {
+ LOGGER.error(
+ "serviceOrderItem {0} for serviceOrder {1} rejected cause service.id is mandatory in delete/change action",
+ serviceOrderItem.getId(), serviceOrderInfo.getServiceOrderId());
+ return false;
+ } else if (!isCustomerFromServiceOrderPresentInInventory(serviceOrderInfo)) {
+ LOGGER
+ .error("serviceOrderItem {0} for serviceOrder {1} rejected cause customer not found in inventory",
+ serviceOrderItem.getId(), serviceOrderInfo.getServiceOrderId());
+ return false;
+ } else if (!existServiceInInventory(serviceOrderItem, serviceOrderItemInfo,
+ serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId())) {
+ LOGGER
+ .error("serviceOrderItem {0} for serviceOrder {1} rejected cause service id {2} not found in inventory",
+ serviceOrderItem.getId(), serviceOrderInfo.getServiceOrderId(),
+ serviceOrderItem.getService().getId());
+ return false;
+ }
+ return true;
+ }
+
private void manageCustomer(ServiceOrder serviceOrder, ServiceOrderInfo serviceOrderInfo) {
RelatedParty customerFromServiceOrder = getCustomerFromServiceOrder(serviceOrder);
SubscriberInfo subscriberInfo = new SubscriberInfo();
@@ -122,25 +172,17 @@ public class CheckOrderConsistenceManager {
private boolean isCustomerFromServiceOrderPresentInInventory(ServiceOrderInfo serviceOrderInfo) {
if (serviceOrderInfo.isUseServiceOrderCustomer()) {
-
- boolean customerPresentInAAI = serviceOrderConsumerService
- .isCustomerPresentInAAI(serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId());
- return customerPresentInAAI;
+ return serviceOrderConsumerService
+ .isCustomerPresentInAAI(serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId());
}
return true;
}
private boolean existServiceInInventory(ServiceOrderItem serviceOrderItem,
- ServiceOrderItemInfo serviceOrderItemInfo, String globalSubscriberId) {
- if (!StringUtils.isEmpty(serviceOrderItem.getService().getId())) {
- String serviceName = (String) serviceOrderItemInfo.getCatalogResponse().get("name");
- boolean serviceExistInInventory = serviceOrderConsumerService.doesServiceExistInServiceInventory(
- serviceOrderItem.getService().getId(), serviceName, globalSubscriberId);
- if (serviceExistInInventory) {
- return true;
- }
- }
- return false;
+ ServiceOrderItemInfo serviceOrderItemInfo, String globalSubscriberId) {
+ String serviceName = (String) serviceOrderItemInfo.getCatalogResponse().get("name");
+ return serviceOrderConsumerService.doesServiceExistInServiceInventory(
+ serviceOrderItem.getService().getId(), serviceName, globalSubscriberId);
}
private boolean existServiceInCatalog(ServiceOrderItemInfo serviceOrderItemInfo) {
@@ -148,13 +190,16 @@ public class CheckOrderConsistenceManager {
}
private void handleServiceFromCatalog(ServiceOrderItem serviceOrderItem,
- ServiceOrderItemInfo serviceOrderItemInfo) {
+ ServiceOrderItemInfo serviceOrderItemInfo) {
ResponseEntity<Object> response = serviceOrderConsumerService
- .getServiceCatalog(serviceOrderItem.getService().getServiceSpecification().getId());
+ .getServiceCatalog(serviceOrderItem.getService().getServiceSpecification().getId());
if (response != null && (response.getStatusCode().equals(HttpStatus.OK)
- || response.getStatusCode().equals(HttpStatus.PARTIAL_CONTENT))) {
+ || response.getStatusCode().equals(HttpStatus.PARTIAL_CONTENT))) {
LinkedHashMap body = (LinkedHashMap) response.getBody();
serviceOrderItemInfo.setCatalogResponse(body);
+ } else {
+ LOGGER.error("unable to retrieve catalog information for service {0}",
+ serviceOrderItem.getService().getServiceSpecification().getId());
}
}
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAICustomerManager.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAICustomerManager.java
index 516444a..efc7e46 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAICustomerManager.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAICustomerManager.java
@@ -1,22 +1,25 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * 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
+ * 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
+ * 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.
+ * 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 java.util.Date;
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.repositories.ServiceOrderRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -27,14 +30,25 @@ public class CreateAAICustomerManager {
@Autowired
private MultiClient serviceOrderConsumerService;
+ @Autowired
+ ServiceOrderRepository serviceOrderRepository;
- public void createAAICustomer(ServiceOrderInfo serviceOrderInfo) {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CreateAAICustomerManager.class);
+ public void createAAICustomer(ServiceOrder serviceOrder,
+ ServiceOrderInfo serviceOrderInfo) {
if (serviceOrderInfo.isUseServiceOrderCustomer() && serviceOrderInfo.isAllItemsInAdd()
- && !serviceOrderConsumerService
- .isCustomerPresentInAAI(serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId())) {
- serviceOrderConsumerService.putCustomer(serviceOrderInfo.getSubscriberInfo());
+ && !serviceOrderConsumerService
+ .isCustomerPresentInAAI(serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId())) {
+
+ boolean customerCreated = serviceOrderConsumerService.putCustomer(serviceOrderInfo.getSubscriberInfo());
+ if (!customerCreated) {
+ serviceOrder.setState(StateType.REJECTED);
+ serviceOrder.setCompletionDateTime(new Date());
+ serviceOrderRepository.save(serviceOrder);
+ LOGGER.error("serviceOrder {0} rejected : cannot create customer", serviceOrder.getId());
+ }
}
}
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 f98eef5..fb0c2bc 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
@@ -1,26 +1,28 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * 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
+ * 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
+ * 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.
+ * 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 java.util.Date;
import org.onap.nbi.apis.serviceorder.MultiClient;
import org.onap.nbi.apis.serviceorder.model.ActionType;
import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
+import org.onap.nbi.apis.serviceorder.model.StateType;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderItemInfo;
+import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.LinkedHashMap;
@@ -32,20 +34,30 @@ public class CreateAAIServiceTypeManager {
@Autowired
private MultiClient serviceOrderConsumerService;
+ @Autowired
+ ServiceOrderRepository serviceOrderRepository;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CreateAAIServiceTypeManager.class);
public void createAAIServiceType(ServiceOrder serviceOrder, ServiceOrderInfo serviceOrderInfo) {
LinkedHashMap servicesInAaiForCustomer = serviceOrderConsumerService
- .getServicesInAaiForCustomer(serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId());
+ .getServicesInAaiForCustomer(serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId());
for (ServiceOrderItem serviceOrderItem : serviceOrder.getOrderItem()) {
if (ActionType.ADD == serviceOrderItem.getAction()) {
ServiceOrderItemInfo serviceOrderItemInfo =
- serviceOrderInfo.getServiceOrderItemInfos().get(serviceOrderItem.getId());
+ serviceOrderInfo.getServiceOrderItemInfos().get(serviceOrderItem.getId());
String sdcServiceName = (String) serviceOrderItemInfo.getCatalogResponse().get("name");
if (!serviceNameExistsInAAI(servicesInAaiForCustomer, sdcServiceName)) {
- serviceOrderConsumerService.putServiceType(
- serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId(), sdcServiceName);
+ boolean serviceCreated = serviceOrderConsumerService.putServiceType(
+ serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId(), sdcServiceName);
+ if (!serviceCreated) {
+ serviceOrder.setState(StateType.REJECTED);
+ serviceOrder.setCompletionDateTime(new Date());
+ serviceOrderRepository.save(serviceOrder);
+ LOGGER.error("serviceOrder {0} rejected : cannot create customer", serviceOrder.getId());
+ }
}
}
}
@@ -56,7 +68,7 @@ public class CreateAAIServiceTypeManager {
if (servicesInAaiForCustomer != null && servicesInAaiForCustomer.get("service-subscription") != null) {
List<LinkedHashMap> servicesInAAI =
- (List<LinkedHashMap>) servicesInAaiForCustomer.get("service-subscription");
+ (List<LinkedHashMap>) servicesInAaiForCustomer.get("service-subscription");
for (LinkedHashMap service : servicesInAAI) {
String serviceType = (String) service.get("service-type");
if (sdcServiceName.equalsIgnoreCase(serviceType)) {
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java
index 954c1c3..0aa26b1 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java
@@ -1,15 +1,14 @@
/**
* Copyright (c) 2018 Orange
*
- * 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
+ * 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.
+ * 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;
@@ -22,9 +21,7 @@ import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ExecutionTask;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
-import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfoJson;
import org.onap.nbi.apis.serviceorder.repositories.ExecutionTaskRepository;
-import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderInfoRepository;
import org.onap.nbi.apis.serviceorder.utils.JsonEntityConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,9 +38,6 @@ public class SOTaskManager {
private ExecutionTaskRepository executionTaskRepository;
@Autowired
- private ServiceOrderInfoRepository serviceOrderInfoRepository;
-
- @Autowired
private SOTaskProcessor soTaskProcessor;
private static final Logger LOGGER = LoggerFactory.getLogger(SOTaskManager.class);
@@ -53,7 +47,7 @@ public class SOTaskManager {
* @param serviceOrderInfoJson
*/
private void registerOrderItemExecutionPlan(List<ServiceOrderItem> orderItems,
- ServiceOrderInfoJson serviceOrderInfoJson) {
+ String serviceOrderInfoJson) {
List<ExecutionTask> executionTasksSaved = new ArrayList<>();
Map<String, Long> internalIdOrderItemsMap = new HashMap<>();
if (orderItems != null) {
@@ -76,7 +70,7 @@ public class SOTaskManager {
for (ExecutionTask executionTask : executionTasksSaved) {
for (String key : internalIdOrderItemsMap.keySet()) {
String replace = executionTask.getReliedTasks().replace(key,
- String.valueOf(internalIdOrderItemsMap.get(key)));
+ String.valueOf(internalIdOrderItemsMap.get(key)));
executionTask.setReliedTasks(replace);
}
executionTaskRepository.save(executionTask);
@@ -90,9 +84,7 @@ public class SOTaskManager {
* @param serviceOrderInfo
*/
public void registerServiceOrder(ServiceOrder serviceOrder, ServiceOrderInfo serviceOrderInfo) {
- String json = JsonEntityConverter.convertServiceOrderInfoToJson(serviceOrderInfo);
- ServiceOrderInfoJson serviceOrderInfoJson = new ServiceOrderInfoJson(serviceOrder.getId(), json);
- serviceOrderInfoRepository.save(serviceOrderInfoJson);
+ String serviceOrderInfoJson = JsonEntityConverter.convertServiceOrderInfoToJson(serviceOrderInfo);
registerOrderItemExecutionPlan(serviceOrder.getOrderItem(), serviceOrderInfoJson);
}
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java
index d623b89..4b36f98 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java
@@ -1,15 +1,14 @@
/**
* Copyright (c) 2018 Orange
*
- * 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
+ * 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.
+ * 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;
@@ -21,10 +20,10 @@ import org.onap.nbi.apis.serviceorder.model.StateType;
import org.onap.nbi.apis.serviceorder.model.consumer.*;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ExecutionTask;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
-import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfoJson;
import org.onap.nbi.apis.serviceorder.repositories.ExecutionTaskRepository;
import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderRepository;
import org.onap.nbi.apis.serviceorder.utils.JsonEntityConverter;
+import org.onap.nbi.exceptions.TechnicalException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -69,49 +68,30 @@ public class SOTaskProcessor {
public void processOrderItem(ExecutionTask executionTask) throws InterruptedException {
- ServiceOrderInfoJson serviceOrderInfoJson = executionTask.getServiceOrderInfoJson();
- ServiceOrder serviceOrder = serviceOrderRepository.findOne(serviceOrderInfoJson.getServiceOrderId());
- ServiceOrderItem serviceOrderItem = null;
- for (ServiceOrderItem item : serviceOrder.getOrderItem()) {
- if (item.getId().equals(executionTask.getOrderItemId())) {
- serviceOrderItem = item;
- }
- }
+ ServiceOrderInfo serviceOrderInfo = getServiceOrderInfo(executionTask);
+
+
+ ServiceOrder serviceOrder = serviceOrderRepository.findOne(serviceOrderInfo.getServiceOrderId());
+ ServiceOrderItem serviceOrderItem = getServiceOrderItem(executionTask, serviceOrder);
- ServiceOrderInfo serviceOrderInfo = null;
- try {
- serviceOrderInfo =
- JsonEntityConverter.convertJsonToServiceOrderInfo(serviceOrderInfoJson.getServiceOrderInfoJson());
- } catch (IOException e) {
- LOGGER.warn("Unable to read ServiceOrderInfo Json for serviceOrderId " + serviceOrder.getId(), e);
- }
if (serviceOrderItem != null && StateType.ACKNOWLEDGED == serviceOrderItem.getState()) {
- ResponseEntity<CreateServiceInstanceResponse> response = null;
- try {
- response = postSORequest(serviceOrderItem, serviceOrderInfo);
- } catch (NullPointerException e) {
- LOGGER.warn("Enable to create service instance for serviceOrderItem.id=" + serviceOrderItem.getId(), e);
- response = null;
- }
+ ResponseEntity<CreateServiceInstanceResponse> response = postServiceOrderItem(serviceOrderInfo,
+ serviceOrderItem);
if (response == null) {
LOGGER.warn("response=null for serviceOrderItem.id=" + serviceOrderItem.getId());
serviceOrderItem.setState(StateType.FAILED);
} else {
- updateServiceOrderItem(response.getBody(), serviceOrderItem);
+ updateServiceOrderItem(response, serviceOrderItem);
+
- if (response.getStatusCode() != HttpStatus.CREATED || response.getBody() == null
- || response.getBody().getRequestReferences() == null) {
- serviceOrderItem.setState(StateType.FAILED);
- } else {
- serviceOrderItem.setState(StateType.INPROGRESS);
- }
}
}
- if (executionTask.getNbRetries() > 0) {
+ if (executionTask.getNbRetries() > 0 && StateType.FAILED != serviceOrderItem.getState()
+ ) {
// TODO lancer en asynchrone
pollSoRequestStatus(serviceOrderItem);
if (serviceOrderItem.getState().equals(StateType.COMPLETED)) {
@@ -126,15 +106,49 @@ public class SOTaskProcessor {
updateFailedTask(executionTask, serviceOrder);
}
-
updateServiceOrder(serviceOrder);
}
+ private ResponseEntity<CreateServiceInstanceResponse> postServiceOrderItem(ServiceOrderInfo serviceOrderInfo,
+ ServiceOrderItem serviceOrderItem) {
+ ResponseEntity<CreateServiceInstanceResponse> response = null;
+ try {
+ response = postSORequest(serviceOrderItem, serviceOrderInfo);
+ } catch (NullPointerException e) {
+ LOGGER.warn("Enable to create service instance for serviceOrderItem.id=" + serviceOrderItem.getId(), e);
+ response = null;
+ }
+ return response;
+ }
+
+ private ServiceOrderItem getServiceOrderItem(ExecutionTask executionTask, ServiceOrder serviceOrder) {
+ ServiceOrderItem serviceOrderItem = null;
+ for (ServiceOrderItem item : serviceOrder.getOrderItem()) {
+ if (item.getId().equals(executionTask.getOrderItemId())) {
+ serviceOrderItem = item;
+ }
+ }
+ return serviceOrderItem;
+ }
+
+ private ServiceOrderInfo getServiceOrderInfo(ExecutionTask executionTask) {
+ String serviceOrderInfoJson = executionTask.getServiceOrderInfoJson();
+ ServiceOrderInfo serviceOrderInfo = null;
+ try {
+ serviceOrderInfo =
+ JsonEntityConverter.convertJsonToServiceOrderInfo(serviceOrderInfoJson);
+ } catch (IOException e) {
+ LOGGER.error("Unable to read ServiceOrderInfo Json for executionTaskId " + executionTask.getInternalId(), e);
+ throw new TechnicalException("Unable to read ServiceOrderInfo Json for executionTaskId " + executionTask.getInternalId());
+ }
+ return serviceOrderInfo;
+ }
+
private ResponseEntity<CreateServiceInstanceResponse> postSORequest(ServiceOrderItem serviceOrderItem,
- ServiceOrderInfo serviceOrderInfo) {
+ ServiceOrderInfo serviceOrderInfo) {
RequestDetails requestDetails = buildSoRequest(serviceOrderItem,
- serviceOrderInfo.getServiceOrderItemInfos().get(serviceOrderItem.getId()).getCatalogResponse(),
- serviceOrderInfo.getSubscriberInfo());
+ serviceOrderInfo.getServiceOrderItemInfos().get(serviceOrderItem.getId()).getCatalogResponse(),
+ serviceOrderInfo.getSubscriberInfo());
MSOPayload msoPayload = new MSOPayload(requestDetails);
ResponseEntity<CreateServiceInstanceResponse> response = null;
@@ -156,7 +170,6 @@ public class SOTaskProcessor {
boolean atLeastOneNotFinished = false;
boolean atLeastOneFailed = false;
-
for (ServiceOrderItem serviceOrderItem : serviceOrder.getOrderItem()) {
switch (serviceOrderItem.getState()) {
case COMPLETED:
@@ -237,7 +250,7 @@ public class SOTaskProcessor {
* @return
*/
private RequestDetails buildSoRequest(ServiceOrderItem orderItem, LinkedHashMap<String, Object> sdcInfos,
- SubscriberInfo subscriberInfo) {
+ SubscriberInfo subscriberInfo) {
RequestDetails requestDetails = new RequestDetails();
requestDetails.setSubscriberInfo(subscriberInfo);
@@ -261,7 +274,7 @@ public class SOTaskProcessor {
RequestParameters requestParameters = new RequestParameters();
requestParameters.setSubscriptionServiceType((String) sdcInfos.get("name"));
requestParameters.setUserParams(
- retrieveUserParamsFromServiceCharacteristics(orderItem.getService().getServiceCharacteristic()));
+ retrieveUserParamsFromServiceCharacteristics(orderItem.getService().getServiceCharacteristic()));
requestParameters.setaLaCarte(true);
requestDetails.setRequestParameters(requestParameters);
@@ -283,7 +296,7 @@ public class SOTaskProcessor {
if (!CollectionUtils.isEmpty(characteristics)) {
for (ServiceCharacteristic characteristic : characteristics) {
UserParams userParam = new UserParams(characteristic.getName(),
- characteristic.getValue().getServiceCharacteristicValue());
+ characteristic.getValue().getServiceCharacteristicValue());
userParams.add(userParam);
}
}
@@ -295,16 +308,24 @@ public class SOTaskProcessor {
/**
* Update ServiceOrderItem with SO response by using serviceOrderRepository with the serviceOrderId
*
- * @param createServiceInstanceResponse
+ * @param response
* @param orderItem
*/
- private void updateServiceOrderItem(CreateServiceInstanceResponse createServiceInstanceResponse,
- ServiceOrderItem orderItem) {
+ private void updateServiceOrderItem(ResponseEntity<CreateServiceInstanceResponse> response,
+ ServiceOrderItem orderItem) {
+ CreateServiceInstanceResponse createServiceInstanceResponse=response.getBody();
if (createServiceInstanceResponse != null && !orderItem.getState().equals(StateType.FAILED)) {
orderItem.getService().setId(createServiceInstanceResponse.getRequestReferences().getInstanceId());
orderItem.setRequestId(createServiceInstanceResponse.getRequestReferences().getRequestId());
}
+
+ if (response.getStatusCode() != HttpStatus.CREATED || response.getBody() == null
+ || response.getBody().getRequestReferences() == null) {
+ orderItem.setState(StateType.FAILED);
+ } else {
+ orderItem.setState(StateType.INPROGRESS);
+ }
}
/**
@@ -315,6 +336,7 @@ public class SOTaskProcessor {
private void updateSuccessTask(ExecutionTask executionTask) {
executionTaskRepository.delete(executionTask.getInternalId());
executionTaskRepository.updateReliedTaskAfterDelete(executionTask.getInternalId());
+
}
/**
@@ -326,7 +348,6 @@ public class SOTaskProcessor {
for (ExecutionTask taskId : executionTasksToDelete) {
executionTaskRepository.delete(taskId);
}
-
for (ServiceOrderItem item : serviceOrder.getOrderItem()) {
for (ExecutionTask taskToDelete : executionTasksToDelete) {
if (taskToDelete.getOrderItemId().equals(item.getId())) {
@@ -345,7 +366,7 @@ public class SOTaskProcessor {
List<ExecutionTask> executionTasks = new ArrayList<>();
List<ExecutionTask> tasksReliedToAnOrderItemId =
- executionTaskRepository.findTasksReliedToAnOrderItemId(executionTask.getInternalId());
+ executionTaskRepository.findTasksReliedToAnOrderItemId(executionTask.getInternalId());
if (CollectionUtils.isEmpty(tasksReliedToAnOrderItemId)) {
return Arrays.asList(executionTask);