aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.env4
-rw-r--r--Dockerfile2
-rw-r--r--pom.xml26
-rw-r--r--src/main/java/org/onap/nbi/apis/hub/service/EventFactory.java3
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java11
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/utils/JsonEntityConverter.java3
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java4
-rw-r--r--src/main/java/org/onap/nbi/commons/JacksonFilter.java3
-rw-r--r--src/main/resources/application.properties4
-rw-r--r--src/main/resources/jolt/getServiceInventory.json1
-rw-r--r--src/test/java/org/onap/nbi/apis/ApiTest.java16
-rw-r--r--src/test/resources/application.properties4
-rw-r--r--src/test/resources/mappings/aai_get_service-subscription-Ansible-service.json52
13 files changed, 116 insertions, 17 deletions
diff --git a/.env b/.env
index 38d05d7..71f7de7 100644
--- a/.env
+++ b/.env
@@ -15,7 +15,7 @@
#
# APPLICATION
-SERVER_CONTEXTPATH=/nbi/api/v1
+SERVER_CONTEXTPATH=/nbi/api/v3
SERVER_PORT=8080
# ONAP
@@ -25,7 +25,7 @@ ONAP_CLOUDOWNER=
NEXUS_DOCKER_REPO=nexus3.onap.org:10001
# NBI
-NBI_URL=http://localhost:8080/nbi/api/v1
+NBI_URL=http://localhost:8080/nbi/api/v3
NBI_CALLFORVNF=false
# SDC
diff --git a/Dockerfile b/Dockerfile
index 7eb5d81..ccf2531 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -17,7 +17,7 @@
FROM openjdk:8-jre-alpine
ARG SERVER_PORT
-ARG PKG_FILENAME=nbi-rest-services-1.0.0-SNAPSHOT.jar
+ARG PKG_FILENAME=nbi-rest-services-3.0.0-SNAPSHOT.jar
ADD target/$PKG_FILENAME app.jar
COPY src/main/resources/certificate /certs
diff --git a/pom.xml b/pom.xml
index 0aa9fde..1a42cd8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -121,6 +121,12 @@
</dependency>
<dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.8.11.2</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>8.5.32</version>
@@ -163,7 +169,7 @@
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
- <version>1.7.0</version>
+ <version>1.9.3</version>
</dependency>
<dependency>
@@ -227,6 +233,12 @@
<groupId>com.bazaarvoice.jolt</groupId>
<artifactId>json-utils</artifactId>
<version>0.1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- test -->
@@ -259,6 +271,12 @@
<artifactId>spring-cloud-contract-wiremock</artifactId>
<version>1.0.0.RELEASE</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
@@ -293,6 +311,12 @@
<groupId>org.onap.msb.java-sdk</groupId>
<artifactId>msb-java-sdk</artifactId>
<version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
diff --git a/src/main/java/org/onap/nbi/apis/hub/service/EventFactory.java b/src/main/java/org/onap/nbi/apis/hub/service/EventFactory.java
index 8083fff..b2a017c 100644
--- a/src/main/java/org/onap/nbi/apis/hub/service/EventFactory.java
+++ b/src/main/java/org/onap/nbi/apis/hub/service/EventFactory.java
@@ -16,6 +16,7 @@
package org.onap.nbi.apis.hub.service;
import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.MappingJsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onap.nbi.apis.hub.model.Event;
@@ -30,7 +31,7 @@ import java.util.UUID;
public class EventFactory {
- private static final ObjectMapper mapper = new ObjectMapper();
+ private static final ObjectMapper mapper = new ObjectMapper(new MappingJsonFactory());
public static Event getEvent(EventType eventType, ServiceOrder serviceOrder, ServiceOrderItem serviceOrderItem) {
Event event = new Event();
diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
index a09917c..b9afe64 100644
--- a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
+++ b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
@@ -81,10 +81,13 @@ public class AaiClient extends BaseClient {
public Map getVNF(String relatedLink) {
StringBuilder callURL = new StringBuilder().append(aaiHost).append(relatedLink);
-
- ResponseEntity<Object> response = callApiGet(callURL.toString(), buildRequestHeaderForAAI());
- return (LinkedHashMap) response.getBody();
-
+ try{
+ ResponseEntity<Object> response = callApiGet(callURL.toString(), buildRequestHeaderForAAI());
+ return (LinkedHashMap) response.getBody();
+ } catch (BackendFunctionalException e) {
+ LOGGER.error("error on calling {} , {}" , callURL.toString(), e);
+ return null;
+ }
}
public Map getServicesInAaiForCustomer(String customerId) {
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/utils/JsonEntityConverter.java b/src/main/java/org/onap/nbi/apis/serviceorder/utils/JsonEntityConverter.java
index 7be84c2..1821f0a 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/utils/JsonEntityConverter.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/utils/JsonEntityConverter.java
@@ -15,6 +15,7 @@
*/
package org.onap.nbi.apis.serviceorder.utils;
+import com.fasterxml.jackson.databind.MappingJsonFactory;
import java.io.IOException;
import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -24,7 +25,7 @@ public final class JsonEntityConverter {
private JsonEntityConverter() {
}
- private static final ObjectMapper MAPPER = new ObjectMapper();
+ private static final ObjectMapper MAPPER = new ObjectMapper(new MappingJsonFactory());
public static String convertServiceOrderInfoToJson(ServiceOrderInfo serviceOrderInfo) {
return MAPPER.valueToTree(serviceOrderInfo).toString();
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 3365525..fa1d5a2 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
@@ -94,8 +94,8 @@ public class SOTaskManager {
registerOrderItemExecutionPlan(serviceOrder.getOrderItem(), serviceOrderInfoJson);
}
-
- @Scheduled(fixedRate = 2000)
+ // Using fixedDelay to mitigate against Scheduler queue backlog with fixedRate
+ @Scheduled(fixedDelay = 2000)
private void processExecutionPlan() throws InterruptedException {
List<ExecutionTask> taskToExecute = executionTaskRepository.findByReliedTasksIsEmpty();
for (ExecutionTask executionTask : taskToExecute) {
diff --git a/src/main/java/org/onap/nbi/commons/JacksonFilter.java b/src/main/java/org/onap/nbi/commons/JacksonFilter.java
index 07c113e..97f6cf2 100644
--- a/src/main/java/org/onap/nbi/commons/JacksonFilter.java
+++ b/src/main/java/org/onap/nbi/commons/JacksonFilter.java
@@ -15,6 +15,7 @@
*/
package org.onap.nbi.commons;
+import com.fasterxml.jackson.databind.MappingJsonFactory;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
@@ -59,7 +60,7 @@ public class JacksonFilter {
}
public static <R> ObjectNode createNode(R bean, JsonRepresentation jsonRepresentation) {
- ObjectMapper mapper = new ObjectMapper();
+ ObjectMapper mapper = new ObjectMapper(new MappingJsonFactory());
return JacksonFilter.createNode(mapper, bean, jsonRepresentation.getAttributes());
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 8c07ce0..11638c1 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -15,7 +15,7 @@
#
# SERVER
-server.contextPath=/nbi/api/v1
+server.contextPath=/nbi/api/v3
server.port=8080
# LOGGING
@@ -27,7 +27,7 @@ onap.tenantId=6e97a2bd51d74f6db5671d8dc1517d82
onap.cloudOwner=CloudOwner
# NBI
-nbi.url=http://localhost:8080/nbi/api/v1
+nbi.url=http://localhost:8080/nbi/api/v3
nbi.callForVNF=false
# SDC
diff --git a/src/main/resources/jolt/getServiceInventory.json b/src/main/resources/jolt/getServiceInventory.json
index df4f14c..cb75530 100644
--- a/src/main/resources/jolt/getServiceInventory.json
+++ b/src/main/resources/jolt/getServiceInventory.json
@@ -4,6 +4,7 @@
"spec": {
"service-instance-id": "id",
"service-instance-name": "name",
+ "orchestration-status": "state",
"model-version-id" : "serviceSpecification.id",
"model-invariant-id": "serviceSpecification.invariantUUID",
"vnfs" : {
diff --git a/src/test/java/org/onap/nbi/apis/ApiTest.java b/src/test/java/org/onap/nbi/apis/ApiTest.java
index ad4a956..4d24062 100644
--- a/src/test/java/org/onap/nbi/apis/ApiTest.java
+++ b/src/test/java/org/onap/nbi/apis/ApiTest.java
@@ -24,6 +24,7 @@ import com.github.tomakehurst.wiremock.stubbing.ListStubMappingsResult;
import com.github.tomakehurst.wiremock.stubbing.StubMapping;
import java.util.ArrayList;
import java.util.Date;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import javax.validation.Validation;
@@ -208,6 +209,21 @@ public class ApiTest {
}
@Test
+ public void testServiceResourceGetInventoryWithStatus() throws Exception {
+
+ String serviceName = "AnsibleService";
+ String serviceId = "405c8c00-44b9-4303-9f27-6797d22ca096";
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+ params.add("serviceSpecification.name", serviceName);
+ params.add("relatedParty.id", "6490");
+ ResponseEntity<Object> resource = serviceInventoryResource.getServiceInventory(serviceId, params);
+ LinkedHashMap service = (LinkedHashMap) resource.getBody();
+ assertThat(service.get("state")).isEqualTo("Active");
+
+
+ }
+
+ @Test
public void testServiceResourceGetInventoryWithoutRelationShipList() throws Exception {
String serviceName = "vFW";
diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties
index 50e0527..c598a89 100644
--- a/src/test/resources/application.properties
+++ b/src/test/resources/application.properties
@@ -15,7 +15,7 @@
#
# SERVER
-server.contextPath=/nbi/api/v1
+server.contextPath=/nbi/api/v3
server.port = 8080
# LOGGING
@@ -27,7 +27,7 @@ onap.tenantId=31047205ce114b60833b23e400d6a535
onap.cloudOwner=CloudOwner
# NBI
-nbi.url=http://127.0.0.1:8080/nbi/api/v1
+nbi.url=http://127.0.0.1:8080/nbi/api/v3
nbi.callForVNF=false
# SDC
diff --git a/src/test/resources/mappings/aai_get_service-subscription-Ansible-service.json b/src/test/resources/mappings/aai_get_service-subscription-Ansible-service.json
new file mode 100644
index 0000000..10bcac8
--- /dev/null
+++ b/src/test/resources/mappings/aai_get_service-subscription-Ansible-service.json
@@ -0,0 +1,52 @@
+{
+ "request": {
+ "method": "GET",
+ "url": "/aai/v11/business/customers/customer/6490/service-subscriptions/service-subscription/AnsibleService/service-instances/service-instance/405c8c00-44b9-4303-9f27-6797d22ca096"
+ },
+ "response": {
+ "status": 200,
+ "jsonBody": {
+ "service-instance-id": "405c8c00-44b9-4303-9f27-6797d22ca096",
+ "service-instance-name": "ansibleService-service-instance-065FYE",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-invariant-id": "f3ec9092-5c98-41f1-9fea-96be80abd064",
+ "model-version-id": "0bf5f56a-4506-4e98-ab50-336d73ca4b07",
+ "resource-version": "1530200875713",
+ "orchestration-status": "Active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/3f73377f-d9be-4a33-b068-e3f35b5b770b",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "3f73377f-d9be-4a33-b068-e3f35b5b770b"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "ansibleService-vnf-instance-DebianVNF_0_065FYE"
+ }
+ ]
+ },
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/OE-generic",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "OE-generic"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ "headers": {
+ "Content-Type": "application/json"
+ }
+ }
+} \ No newline at end of file