summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java5
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java43
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/ServiceOrderResource.java7
-rwxr-xr-xsrc/main/java/org/onap/nbi/apis/serviceorder/model/StateType.java21
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestDetails.java12
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestParameters.java17
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderInfo.java9
-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
-rw-r--r--src/main/java/org/onap/nbi/commons/MultiCriteriaRequestBuilder.java3
-rw-r--r--src/main/resources/application-test.properties2
-rw-r--r--src/main/resources/application.properties8
12 files changed, 184 insertions, 24 deletions
diff --git a/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java b/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java
index d9d2cb9..602b88c 100644
--- a/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java
+++ b/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java
@@ -55,7 +55,10 @@ public final class OnapComponentsUrlPaths {
"/aai/v14/nodes/service-instances/service-instance/$serviceId?format=resource_and_url";
public static final String AAI_GET_SERVICE_INSTANCES_PATH =
"/aai/v14/business/customers/customer/$customerId/service-subscriptions/service-subscription/$serviceSpecName/service-instances/";
-
+ public static final String AAI_GET_OWNING_ENTITIES =
+ "/aai/v14/business/owning-entities";
+ public static final String AAI_PUT_OWNING_ENTITIES =
+ "/aai/v14/business/owning-entities/owning-entity/$onap.owning.entity.id";
// MSO
public static final String MSO_CREATE_SERVICE_INSTANCE_PATH = "/onap/so/infra/serviceInstantiation/v7/serviceInstances/";
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 2bc654b..6a38fbc 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java
@@ -69,6 +69,12 @@ public class MultiClient {
@Value("${onap.cloudOwner}")
private String cloudOwner;
+ @Value("${so.owning.entity.id}")
+ private String owningEntityId;
+
+ @Value("${so.owning.entity.name}")
+ private String owningEntityName;
+
@Autowired
private ServiceCatalogUrl serviceCatalogUrl;
@@ -148,6 +154,27 @@ public class MultiClient {
return false;
}
+
+ public String getOwningEntityIdInAAI(ServiceOrder serviceOrder) {
+ StringBuilder callURL = new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_OWNING_ENTITIES);
+ String callUrlFormated = callURL.toString();
+
+ ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI(), null);
+ if (response.getStatusCode().is2xxSuccessful()) {
+ LinkedHashMap body = (LinkedHashMap) response.getBody();
+ List<LinkedHashMap> owningEntities = (List<LinkedHashMap>) body.get("owning-entity");
+ for (LinkedHashMap owningEntity : owningEntities) {
+ if (owningEntityName.equalsIgnoreCase((String) owningEntity.get("owning-entity-name"))) {
+ return owningEntity.get("owning-entity-id").toString();
+ }
+ }
+ } else {
+ serviceOrderService.addOrderMessage(serviceOrder, "501");
+ }
+ return null;
+ }
+
+
public boolean isCustomerPresentInAAI(String customerId,
ServiceOrder serviceOrder) {
StringBuilder callURL = new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_CUSTOMER_PATH)
@@ -161,6 +188,22 @@ public class MultiClient {
}
+ public boolean putOwningEntity(ServiceOrder serviceOrder) {
+ Map<String, String> param = new HashMap<>();
+ param.put("owning-entity-id", owningEntityId);
+ param.put("owning-entity-name", owningEntityName);
+ String callURL =
+ aaiHost + OnapComponentsUrlPaths.AAI_PUT_OWNING_ENTITIES;
+ String callUrlFormated = callURL.replace("$onap.owning.entity.id", owningEntityId);
+ ResponseEntity<Object> response = putRequest(param, callUrlFormated, buildRequestHeaderForAAI());
+ if(response.getStatusCode().equals(HttpStatus.INTERNAL_SERVER_ERROR)) {
+ serviceOrderService.addOrderMessage(serviceOrder, "501");
+ return false;
+ }
+ return response.getStatusCode().equals(HttpStatus.CREATED);
+ }
+
+
public boolean putCustomer(SubscriberInfo subscriberInfo,
ServiceOrder serviceOrder) {
Map<String, String> param = new HashMap<>();
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 90d84a4..c48965a 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/ServiceOrderResource.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/ServiceOrderResource.java
@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Optional;
import javax.validation.Valid;
import org.onap.nbi.OnapComponentsUrlPaths;
+import org.onap.nbi.apis.serviceorder.workflow.CreateAAIOwningEntityManager;
import org.onap.nbi.commons.EWInterfaceUtils;
import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.onap.nbi.apis.serviceorder.model.StateType;
@@ -62,6 +63,9 @@ public class ServiceOrderResource extends ResourceManagement {
CreateAAICustomerManager createAAICustomer;
@Autowired
+ CreateAAIOwningEntityManager createAAIOwningEntityManager;
+
+ @Autowired
CreateAAIServiceTypeManager createAAIServiceType;
@Autowired
@@ -158,10 +162,13 @@ public class ServiceOrderResource extends ResourceManagement {
serviceOrderService.updateOrderState(serviceOrder, StateType.COMPLETED);
} else {
createAAICustomer.createAAICustomer(serviceOrder, serviceOrderInfo);
+ createAAIOwningEntityManager.createAAIOwningEntity(serviceOrder, serviceOrderInfo);
+
if (StateType.ACKNOWLEDGED == serviceOrder.getState()) {
createAAIServiceType.createAAIServiceType(serviceOrder, serviceOrderInfo);
if (StateType.ACKNOWLEDGED == serviceOrder.getState()) {
serviceOrchestratorManager.registerServiceOrder(serviceOrder, serviceOrderInfo);
+ serviceOrderService.updateOrderState(serviceOrder, StateType.INPROGRESS_TASK_CREATED);
}
}
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/StateType.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/StateType.java
index af5e6e6..9f51eac 100755
--- a/src/main/java/org/onap/nbi/apis/serviceorder/model/StateType.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/model/StateType.java
@@ -40,6 +40,8 @@ package org.onap.nbi.apis.serviceorder.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.ArrayList;
+import java.util.List;
/**
*
@@ -64,6 +66,8 @@ public enum StateType {
PARTIAL("partial"),
+ INPROGRESS_TASK_CREATED("inProgressTaskCreated"),
+
INPROGRESS_MODIFY_REQUEST_DELETE_SEND("inProgressModifyRequestDeleteSend"),
INPROGRESS_MODIFY_ITEM_TO_CREATE("inProgressModifyItemToCreate"),
@@ -92,10 +96,27 @@ public enum StateType {
return null;
}
+ public static List<StateType> fromValueSearch(String text){
+ List<StateType> values = new ArrayList<>();
+ for (StateType b : StateType.values()) {
+ if (String.valueOf(b.value).equals(text)) {
+ if(b.equals(StateType.INPROGRESS)) {
+ values.add(INPROGRESS_TASK_CREATED);
+ values.add(INPROGRESS_MODIFY_REQUEST_DELETE_SEND);
+ values.add(INPROGRESS_MODIFY_ITEM_TO_CREATE);
+ values.add(INPROGRESS_MODIFY_REQUEST_CREATE_SEND);
+ }
+ values.add(b);
+ }
+ }
+ return values;
+ }
+
@JsonValue
public String value()
{
if("inProgressModifyRequestDeleteSend".equalsIgnoreCase(this.value) || "inProgressModifyItemToCreate".equalsIgnoreCase(this.value)
+ || "inProgressTaskCreated".equalsIgnoreCase(this.value)
|| "inProgressModifyRequestCreateSend".equalsIgnoreCase(this.value)) {
return INPROGRESS.value;
}
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestDetails.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestDetails.java
index 2354b39..748af0d 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestDetails.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestDetails.java
@@ -89,8 +89,14 @@ public class RequestDetails {
@Override
public String toString() {
- return "RequestDetails{" + "modelInfo=" + modelInfo + ", subscriberInfo=" + subscriberInfo + ", requestInfo="
- + requestInfo + ", requestParameters=" + requestParameters + ", cloudConfiguration="
- + cloudConfiguration + '}';
+ return "RequestDetails{" +
+ "modelInfo=" + modelInfo +
+ ", subscriberInfo=" + subscriberInfo +
+ ", requestInfo=" + requestInfo +
+ ", requestParameters=" + requestParameters +
+ ", cloudConfiguration=" + cloudConfiguration +
+ ", owningEntity=" + owningEntity +
+ ", project=" + project +
+ '}';
}
}
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestParameters.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestParameters.java
index e4bbfbb..147ad71 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestParameters.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestParameters.java
@@ -26,6 +26,15 @@ public class RequestParameters {
private boolean aLaCarte;
+ private String testApi;
+
+ public String getTestApi() {
+ return testApi;
+ }
+
+ public void setTestApi(String testApi) {
+ this.testApi = testApi;
+ }
public String getSubscriptionServiceType() {
return subscriptionServiceType;
@@ -69,7 +78,11 @@ public class RequestParameters {
@Override
public String toString() {
- return "RequestParameters{" + "subscriptionServiceType='" + subscriptionServiceType + '\'' + ", userParams="
- + userParams + ", aLaCarte=" + aLaCarte + '}';
+ return "RequestParameters{" +
+ "subscriptionServiceType='" + subscriptionServiceType + '\'' +
+ ", userParams=" + userParams +
+ ", aLaCarte=" + aLaCarte +
+ ", testApi='" + testApi + '\'' +
+ '}';
}
}
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 fd0eed5..2068fdf 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
@@ -29,6 +29,15 @@ public class ServiceOrderInfo {
private boolean allItemsCompleted;
private boolean serviceOrderRejected= false;
private String serviceOrderId;
+ private String owningEntityId;
+
+ public String getOwningEntityId() {
+ return owningEntityId;
+ }
+
+ public void setOwningEntityId(String owningEntityId) {
+ this.owningEntityId = owningEntityId;
+ }
public String getServiceOrderId() {
return serviceOrderId;
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);
diff --git a/src/main/java/org/onap/nbi/commons/MultiCriteriaRequestBuilder.java b/src/main/java/org/onap/nbi/commons/MultiCriteriaRequestBuilder.java
index 968f1dd..36902fe 100644
--- a/src/main/java/org/onap/nbi/commons/MultiCriteriaRequestBuilder.java
+++ b/src/main/java/org/onap/nbi/commons/MultiCriteriaRequestBuilder.java
@@ -51,8 +51,7 @@ public class MultiCriteriaRequestBuilder {
if (!CollectionUtils.isEmpty(states)) {
String state = states.get(0);
LOGGER.debug("add criterion state {}", state);
- query.addCriteria(Criteria.where("state").is(StateType.fromValue(state)));
-
+ query.addCriteria(Criteria.where("state").in(StateType.fromValueSearch(state)));
}
List<String> descriptions = params.get("description");
if (!CollectionUtils.isEmpty(descriptions)) {
diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties
index 1ab93e3..1a73f16 100644
--- a/src/main/resources/application-test.properties
+++ b/src/main/resources/application-test.properties
@@ -58,7 +58,7 @@ aai.header.transaction.id = 808b54e3-e563-4144-a1b9-e24e2ed93d4f
so.host = http://127.0.0.1:8091
so.header.authorization =
so.api.id = SO
-so.owning.entity.id = 6b5b6b70-4e9a-4f6f-8b7b-cbd7cf990c6e
+so.owning.entity.id = OE-generic
so.owning.entity.name = OE-generic
so.project.name = Project-generic
so.onap.partner.name = NBI
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 2925137..fe0b9d1 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -54,21 +54,21 @@ dmaapCheck.schedule = 10000
dmaapCheck.initial = 1
# SDC
-sdc.host = http://10.0.3.1:8080
+sdc.host = http://localhost:8081
sdc.header.ecompInstanceId = demo
sdc.header.authorization = Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU=
# AAI
-aai.host = https://10.0.1.1:8443
+aai.host = http://localhost:8081
aai.header.authorization = Basic QUFJOkFBSQ==
aai.api.id = NBI
aai.header.transaction.id = 808b54e3-e563-4144-a1b9-e24e2ed93d4f
# SO
-so.host = http://10.0.5.1:8080
+so.host = http://localhost:8081
so.header.authorization = Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
so.api.id = SO
-so.owning.entity.id = 6b5b6b70-4e9a-4f6f-8b7b-cbd7cf990c6e
+so.owning.entity.id = OE-generic
so.owning.entity.name = OE-generic
so.project.name = Project-generic
so.onap.partner.name = NBI