adapt NBI to Beijing 47/55947/1
authorromaingimbert <romain.gimbert@orange.com>
Fri, 6 Jul 2018 09:54:49 +0000 (11:54 +0200)
committerromaingimbert <romain.gimbert@orange.com>
Fri, 6 Jul 2018 10:26:03 +0000 (12:26 +0200)
-change SO Url to "v6"
-add xtransactionid in AAI request header
-add fields Project and OwningEntity in SO request
-fix tests

Change-Id: I61f3ef9f99f4d200cc8f04e7f4929dc1fddf130a
Issue-ID: EXTAPI-117
Signed-off-by: romaingimbert <romain.gimbert@orange.com>
15 files changed:
docs/consumedapis/consumedapis.rst
src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java
src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java
src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java
src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/OwningEntity.java [new file with mode: 0644]
src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/Project.java [new file with mode: 0644]
src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestDetails.java
src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java
src/main/resources/application.properties
src/test/java/org/onap/nbi/apis/ApiTest.java
src/test/resources/application.properties
src/test/resources/mappings/so_delete_service_instance.json
src/test/resources/mappings/so_get_.json
src/test/resources/mappings/so_post_create_service_instance.json

index 4770f55..6ca0932 100644 (file)
@@ -61,9 +61,9 @@ This API is used to perform Service Order and thus instantiate a service
 
 ::
 
-    MSO_CREATE_SERVICE_INSTANCE_PATH = "/ecomp/mso/infra/serviceInstance/v4"
+    MSO_CREATE_SERVICE_INSTANCE_PATH = "/ecomp/mso/infra/serviceInstance/v6"
 
-    MSO_GET_REQUEST_STATUS_PATH = "/ecomp/mso/infra/orchestrationRequests/v4/"
+    MSO_GET_REQUEST_STATUS_PATH = "/ecomp/mso/infra/orchestrationRequests/v6/"
 
-    MSO_DELETE_REQUEST_STATUS_PATH = "/ecomp/mso/infra/serviceInstances/"
+    MSO_DELETE_REQUEST_STATUS_PATH = "/ecomp/mso/infra/serviceInstances/v6/"
 
index 67c72e3..69cc5be 100644 (file)
@@ -42,7 +42,7 @@ public final class OnapComponentsUrlPaths {
             "/aai/v11/business/customers/customer/$customerId/service-subscriptions/service-subscription/$serviceSpecName/service-instances/";
 
     // MSO
-    public static final String MSO_CREATE_SERVICE_INSTANCE_PATH = "/ecomp/mso/infra/serviceInstances/v4";
-    public static final String MSO_GET_REQUEST_STATUS_PATH = "/ecomp/mso/infra/orchestrationRequests/v4/";
-    public static final String MSO_DELETE_REQUEST_STATUS_PATH = "/ecomp/mso/infra/serviceInstances/v4/";
+    public static final String MSO_CREATE_SERVICE_INSTANCE_PATH = "/ecomp/mso/infra/serviceInstances/v6";
+    public static final String MSO_GET_REQUEST_STATUS_PATH = "/ecomp/mso/infra/orchestrationRequests/v6/";
+    public static final String MSO_DELETE_REQUEST_STATUS_PATH = "/ecomp/mso/infra/serviceInstances/v6/";
 }
index 5cd4c35..a09917c 100644 (file)
@@ -41,9 +41,13 @@ public class AaiClient extends BaseClient {
     @Value("${aai.api.id}")
     private String aaiApiId;
 
+    @Value("${aai.header.transaction.id}")
+    private String aaiTransactionId;
+
     private static final String HEADER_AUTHORIZATION = "Authorization";
     private static final String X_FROM_APP_ID = "X-FromAppId";
     private static final Logger LOGGER = LoggerFactory.getLogger(AaiClient.class);
+    private static final String X_TRANSACTION_ID = "X-TransactionId";
 
     private HttpHeaders buildRequestHeaderForAAI() {
 
@@ -52,6 +56,8 @@ public class AaiClient extends BaseClient {
         httpHeaders.add(X_FROM_APP_ID, aaiApiId);
         httpHeaders.add("Accept", "application/json");
         httpHeaders.add("Content-Type", "application/json");
+        httpHeaders.add(X_TRANSACTION_ID, aaiTransactionId);
+
         return httpHeaders;
 
     }
index 4c9d8e5..72ee99e 100644 (file)
@@ -29,13 +29,23 @@ public abstract class BaseClient {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(BaseClient.class);
 
+
     @Autowired
     private RestTemplate restTemplate;
 
+
+
     protected ResponseEntity<Object> callApiGet(String callURL, HttpHeaders httpHeaders) {
 
-        ResponseEntity<Object> response = restTemplate.exchange(callURL, HttpMethod.GET,
-                new HttpEntity<>("parameters", httpHeaders), Object.class);
+
+        if(LOGGER.isDebugEnabled()){
+            LOGGER.debug("log request : "+callURL+ " "+httpHeaders);
+        }
+
+        ResponseEntity<Object> response = null;
+            response = restTemplate.exchange(callURL, HttpMethod.GET,
+                    new HttpEntity<>("parameters", httpHeaders), Object.class);
+
         if(LOGGER.isDebugEnabled()){
             LOGGER.debug("response body : {}",response.getBody().toString());
         }
index 5e4668a..4884485 100644 (file)
@@ -53,6 +53,10 @@ public class MultiClient {
     @Value("${aai.api.id}")
     private String aaiApiId;
 
+    @Value("${aai.header.transaction.id}")
+    private String aaiTransactionId;
+
+
     @Value("${onap.lcpCloudRegionId}")
     private String lcpCloudRegionId;
 
@@ -71,6 +75,7 @@ public class MultiClient {
 
     private static final String HEADER_AUTHORIZATION = "Authorization";
     private static final String X_FROM_APP_ID = "X-FromAppId";
+    private static final String X_TRANSACTION_ID = "X-TransactionId";
 
     private static final Logger LOGGER = LoggerFactory.getLogger(MultiClient.class);
 
@@ -96,6 +101,8 @@ public class MultiClient {
         httpHeaders.add(X_FROM_APP_ID, aaiApiId);
         httpHeaders.add("Accept", "application/json");
         httpHeaders.add("Content-Type", "application/json");
+        httpHeaders.add(X_TRANSACTION_ID, aaiTransactionId);
+
         return httpHeaders;
     }
 
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/OwningEntity.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/OwningEntity.java
new file mode 100644 (file)
index 0000000..fb80d2d
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ *     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.consumer;
+
+public class OwningEntity {
+
+    private String owningEntityId;
+    private String owningEntityName;
+
+    public String getOwningEntityId() {
+        return owningEntityId;
+    }
+
+    public void setOwningEntityId(String owningEntityId) {
+        this.owningEntityId = owningEntityId;
+    }
+
+    public String getOwningEntityName() {
+        return owningEntityName;
+    }
+
+    public void setOwningEntityName(String owningEntityName) {
+        this.owningEntityName = owningEntityName;
+    }
+}
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/Project.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/Project.java
new file mode 100644 (file)
index 0000000..fca5391
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ *     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.consumer;
+
+public class Project {
+
+    private String projectName;
+
+    public String getProjectName() {
+        return projectName;
+    }
+
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+    }
+}
index da5b1ad..2354b39 100644 (file)
@@ -27,6 +27,25 @@ public class RequestDetails {
 
     private CloudConfiguration cloudConfiguration;
 
+    private OwningEntity owningEntity;
+
+    private Project project;
+
+    public Project getProject() {
+        return project;
+    }
+
+    public void setProject(Project project) {
+        this.project = project;
+    }
+
+    public OwningEntity getOwningEntity() {
+        return owningEntity;
+    }
+
+    public void setOwningEntity(OwningEntity owningEntity) {
+        this.owningEntity = owningEntity;
+    }
 
     public CloudConfiguration getCloudConfiguration() {
         return cloudConfiguration;
index 66bb408..def4fe0 100644 (file)
@@ -28,6 +28,8 @@ import org.onap.nbi.apis.serviceorder.model.consumer.CreateServiceInstanceRespon
 import org.onap.nbi.apis.serviceorder.model.consumer.GetRequestStatusResponse;
 import org.onap.nbi.apis.serviceorder.model.consumer.MSOPayload;
 import org.onap.nbi.apis.serviceorder.model.consumer.ModelInfo;
+import org.onap.nbi.apis.serviceorder.model.consumer.OwningEntity;
+import org.onap.nbi.apis.serviceorder.model.consumer.Project;
 import org.onap.nbi.apis.serviceorder.model.consumer.RequestDetails;
 import org.onap.nbi.apis.serviceorder.model.consumer.RequestInfo;
 import org.onap.nbi.apis.serviceorder.model.consumer.RequestParameters;
@@ -60,6 +62,15 @@ public class SOTaskProcessor {
     @Value("${onap.tenantId}")
     private String tenantId;
 
+    @Value("${so.owning.entity.id}")
+    private String soOwningEntityId;
+
+    @Value("${so.owning.entity.name}")
+    private String soOwningEntityName;
+
+    @Value("${so.project.name}")
+    private String soProjectName;
+
 
     @Autowired
     private ServiceOrderService serviceOrderService;
@@ -289,6 +300,17 @@ public class SOTaskProcessor {
 
         CloudConfiguration cloudConfiguration = new CloudConfiguration(lcpCloudRegionId, tenantId);
         requestDetails.setCloudConfiguration(cloudConfiguration);
+
+        OwningEntity owningEntity = new OwningEntity();
+        owningEntity.setOwningEntityId(soOwningEntityId);
+        owningEntity.setOwningEntityName(soOwningEntityName);
+        requestDetails.setOwningEntity(owningEntity);
+
+        Project project = new Project();
+        project.setProjectName(soProjectName);
+
+        requestDetails.setProject(project);
+
         return requestDetails;
     }
 
index 4e45084..7c9975f 100644 (file)
@@ -38,12 +38,16 @@ sdc.header.authorization=Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2Y
 # AAI
 aai.host=https://10.0.1.1:8443
 aai.header.authorization=Basic QUFJOkFBSQ==
-aai.api.id=AAI
+aai.api.id=NBI
+aai.header.transaction.id=808b54e3-e563-4144-a1b9-e24e2ed93d4f
 
 # SO
 so.host=http://10.0.5.1:8080
 so.header.authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
 so.api.id=SO
+so.owning.entity.id=6b5b6b70-4e9a-4f6f-8b7b-cbd7cf990c6e
+so.owning.entity.name=OE-generic
+so.project.name=Project-generic
 
 # MONGO
 spring.data.mongodb.host=localhost
index 35e89c2..78d5b2a 100644 (file)
@@ -665,7 +665,7 @@ public class ApiTest {
         ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository,
             executionTaskRepository, ActionType.ADD);
 
-        removeWireMockMapping("/ecomp/mso/infra/orchestrationRequests/v4/requestId");
+        removeWireMockMapping("/ecomp/mso/infra/orchestrationRequests/v6/requestId");
 
 
         SoTaskProcessor.processOrderItem(executionTaskA);
@@ -707,7 +707,7 @@ public class ApiTest {
         ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository,
              executionTaskRepository, ActionType.ADD);
 
-        removeWireMockMapping("/ecomp/mso/infra/serviceInstances/v4");
+        removeWireMockMapping("/ecomp/mso/infra/serviceInstances/v6");
 
 
         SoTaskProcessor.processOrderItem(executionTaskA);
@@ -729,8 +729,8 @@ public class ApiTest {
         ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository,
             executionTaskRepository, ActionType.ADD);
 
-        removeWireMockMapping("/ecomp/mso/infra/serviceInstances/v4");
-        removeWireMockMapping("/ecomp/mso/infra/orchestrationRequests/v4/requestId");
+        removeWireMockMapping("/ecomp/mso/infra/serviceInstances/v6");
+        removeWireMockMapping("/ecomp/mso/infra/orchestrationRequests/v6/requestId");
 
 
         SoTaskProcessor.processOrderItem(executionTaskA);
index f6df654..1361d42 100644 (file)
@@ -39,11 +39,15 @@ sdc.header.authorization=Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2Y
 aai.host=http://127.0.0.1:8091
 aai.header.authorization=Basic QUFJOkFBSQ==
 aai.api.id=AAI
+aai.header.transaction.id=808b54e3-e563-4144-a1b9-e24e2ed93d4f
 
 # SO
 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.name=OE-generic
+so.project.name=Project-generic
 
 # H2
 spring.datasource.url=jdbc:h2:mem:~/db;DB_CLOSE_ON_EXIT=false
index b294d0b..141b877 100644 (file)
@@ -1,7 +1,7 @@
 {
     "request": {
         "method": "DELETE",
-        "url": "/ecomp/mso/infra/serviceInstances/v4/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"
+        "url": "/ecomp/mso/infra/serviceInstances/v6/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"
     },
     "response": {
         "status": 202,
index 5d4148f..6fc9c9c 100644 (file)
@@ -1,7 +1,7 @@
 {
     "request": {
         "method": "GET",
-        "url": "/ecomp/mso/infra/orchestrationRequests/v4/requestId"
+        "url": "/ecomp/mso/infra/orchestrationRequests/v6/requestId"
     },
     "response": {
         "status": 200,
index f5aaa90..7724860 100644 (file)
@@ -1,7 +1,7 @@
 {
     "request": {
         "method": "POST",
-        "url": "/ecomp/mso/infra/serviceInstances/v4"
+        "url": "/ecomp/mso/infra/serviceInstances/v6"
     },
     "response": {
         "status": 201,