summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennie Jia <Jennie.Jia@amdocs.com>2018-09-11 15:06:39 +0000
committerJennie Jia <Jennie.Jia@amdocs.com>2018-09-11 21:31:32 +0000
commit5a34dbbd091db590a9a38e5398140933ae9ed639 (patch)
tree5d328b1fbe880311718de905b6dbc159f55d1abe
parent797bf1d50236fddcbbb2ca091729e2e64b047f73 (diff)
Update API and common model mapping
Issue-ID: LOG-646 Change-Id: Ie56d3f697abbafecf9c2d9f73fa52bee1833a469 Signed-off-by: Jennie Jia <Jennie.Jia@amdocs.com>
-rw-r--r--config/application.properties7
-rw-r--r--pom.xml694
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/AAIConfiguration.java8
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/datatype/Vserver.java203
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringService.java2
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringServiceImpl.java11
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/service/rs/RestService.java8
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/service/rs/RestServiceImpl.java11
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java401
-rw-r--r--src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java122
10 files changed, 927 insertions, 540 deletions
diff --git a/config/application.properties b/config/application.properties
index 4ce5de9..dd5a9ac 100644
--- a/config/application.properties
+++ b/config/application.properties
@@ -26,8 +26,8 @@ server.tomcat.max-threads=200
server.tomcat.min-spare-threads=25
# AAI REST Client Configuration
-aai.serviceName=10.12.6.120
-aai.servicePort=30233
+aai.serviceName=10.69.100.132
+aai.servicePort=8443
aai.username=AAI
aai.password=OBF:1gfr1ev31gg7
aai.httpProtocol=https
@@ -38,9 +38,6 @@ aai.readTimeout=1000
http.userId=admin
http.password=OBF:1u2a1toa1w8v1tok1u30
-# {0} = customerId {1} = serviceType {2} = serviceInstanceId
-aai.serviceInstancePath=/aai/v11/business/customers/customer/{0}/service-subscriptions/service-subscription/{1}/service-instances/service-instance/{2}
-
aai.searchNodeQuery=/aai/v11/search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:
#Servlet context parameters
diff --git a/pom.xml b/pom.xml
index bab6e32..ce4ef82 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,148 +1,148 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <groupId>org.onap.logging-analytics.pomba</groupId>
- <artifactId>pomba-aai-context-builder</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <groupId>org.onap.logging-analytics.pomba</groupId>
+ <artifactId>pomba-aai-context-builder</artifactId>
+ <version>1.3.1-SNAPSHOT</version>
- <parent>
- <groupId>org.onap.oparent</groupId>
- <artifactId>oparent</artifactId>
- <version>1.2.0</version>
- <relativePath/>
- </parent>
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>1.2.0</version>
+ <relativePath/>
+ </parent>
- <properties>
- <aai.rest.client.version>1.2.1</aai.rest.client.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <logback.version>1.2.3</logback.version>
- <swagger.directory>${project.build.directory}/generated-resources/swagger</swagger.directory>
- <!--docker -->
- <docker.tag>${project.version}-${timestamp}</docker.tag>
- <docker.latest.tag>${project.version}-latest</docker.latest.tag>
- </properties>
+ <properties>
+ <aai.rest.client.version>1.2.1</aai.rest.client.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <logback.version>1.2.3</logback.version>
+ <swagger.directory>${project.build.directory}/generated-resources/swagger</swagger.directory>
+ <!--docker -->
+ <docker.tag>${project.version}-${timestamp}</docker.tag>
+ <docker.latest.tag>${project.version}-latest</docker.latest.tag>
+ </properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>1.5.12.RELEASE</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>1.5.12.RELEASE</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-security</artifactId>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-security</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-jersey</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.logging-analytics.pomba</groupId>
- <artifactId>pomba-audit-common</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <!-- logging dependencies -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.logging-analytics</groupId>
- <artifactId>logging-slf4j</artifactId>
- <version>1.2.2-SNAPSHOT</version>
- <exclusions>
- <exclusion>
- <groupId>com.att.eelf</groupId>
- <artifactId>eelf-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.7</version>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- </dependency>
- <dependency>
- <groupId>com.jayway.jsonpath</groupId>
- <artifactId>json-path</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.aai</groupId>
- <artifactId>rest-client</artifactId>
- <version>${aai.rest.client.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.onap.aai</groupId>
- <artifactId>rest-client</artifactId>
- <version>${aai.rest.client.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-core</artifactId>
- <version>1.5.9</version>
- </dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- <version>1.5.9</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jersey</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.logging-analytics.pomba</groupId>
+ <artifactId>pomba-audit-common</artifactId>
+ <version>1.3.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+ <!-- logging dependencies -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.logging-analytics</groupId>
+ <artifactId>logging-slf4j</artifactId>
+ <version>1.2.2-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.att.eelf</groupId>
+ <artifactId>eelf-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.jsonpath</groupId>
+ <artifactId>json-path</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.aai</groupId>
+ <artifactId>rest-client</artifactId>
+ <version>${aai.rest.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.aai</groupId>
+ <artifactId>rest-client</artifactId>
+ <version>${aai.rest.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-core</artifactId>
+ <version>1.5.9</version>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>1.5.9</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
@@ -154,219 +154,219 @@
<version>2.18.0</version>
<scope>test</scope>
</dependency>
- </dependencies>
+ </dependencies>
- <build>
- <finalName>${project.artifactId}</finalName>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
- <resources>
- <resource>
- <targetPath>config</targetPath>
- <directory>config</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- </build>
+ <resources>
+ <resource>
+ <targetPath>config</targetPath>
+ <directory>config</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
- <profiles>
- <profile>
- <id>docker</id>
- <build>
- <plugins>
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>0.19.1</version>
- <configuration>
- <verbose>true</verbose>
- <apiVersion>1.23</apiVersion>
- <images>
- <image>
- <name>onap/${project.artifactId}</name>
- <alias>${project.artifactId}</alias>
- <build>
- <cleanup>try</cleanup>
- <dockerFileDir>${project.basedir}/target/docker-stage</dockerFileDir>
- <tags>
- <tag>${docker.snapshot.tag}</tag>
- <tag>${docker.latest.tag}</tag>
- </tags>
- </build>
- </image>
- </images>
- </configuration>
- <executions>
- <execution>
- <id>generate-images</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>build</goal>
- </goals>
- </execution>
- <execution>
- <id>push-images</id>
- <phase>deploy</phase>
- <goals>
- <goal>build</goal>
- <goal>push</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>3.1.0</version>
- <executions>
- <execution>
- <id>copy-resources</id>
- <!-- here the phase you need -->
- <phase>prepare-package</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.outputDirectory}</outputDirectory>
- <resources>
- <resource>
- <directory>
- ${project.build.directory}/generated-resources/swagger
- </directory>
- <targetPath>META-INF/resources/swagger</targetPath>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ <profiles>
+ <profile>
+ <id>docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.19.1</version>
+ <configuration>
+ <verbose>true</verbose>
+ <apiVersion>1.23</apiVersion>
+ <images>
+ <image>
+ <name>onap/${project.artifactId}</name>
+ <alias>${project.artifactId}</alias>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFileDir>${project.basedir}/target/docker-stage</dockerFileDir>
+ <tags>
+ <tag>${docker.snapshot.tag}</tag>
+ <tag>${docker.latest.tag}</tag>
+ </tags>
+ </build>
+ </image>
+ </images>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-images</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>push-images</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <!-- here the phase you need -->
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.outputDirectory}</outputDirectory>
+ <resources>
+ <resource>
+ <directory>
+ ${project.build.directory}/generated-resources/swagger
+ </directory>
+ <targetPath>META-INF/resources/swagger</targetPath>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
- <plugin>
- <groupId>com.github.kongchen</groupId>
- <artifactId>swagger-maven-plugin</artifactId>
- <version>3.1.3</version>
- <configuration>
- <apiSources>
- <apiSource>
- <locations>org.onap.pomba.contextbuilder.aai.service.rs</locations>
- <basePath>/aaicontextbuilder</basePath>
- <info>
- <title>${project.artifactId} Service</title>
- <version>${project.version}</version>
- </info>
- <swaggerDirectory>${swagger.directory}</swaggerDirectory>
- </apiSource>
- </apiSources>
- </configuration>
- <executions>
- <execution>
- <!-- <phase>compile</phase> -->
- <phase>package</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>copy-dockerfile</id>
- <goals>
- <goal>copy-resources</goal>
- </goals><!-- here the phase you need -->
- <phase>package</phase>
- <configuration>
- <outputDirectory>${project.basedir}/target/docker-stage</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/docker</directory>
- <includes>
- <include>Dockerfile</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-properties</id>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <phase>validate</phase>
- <configuration>
- <outputDirectory>${project.basedir}/target/docker-stage/config</outputDirectory>
- <resources>
- <resource>
- <directory>config</directory>
- <includes>
- <include>*.properties</include>
- <include>*.xml</include>
- </includes>
- <filtering>false</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-script</id>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/docker</directory>
- <includes>
- <include>*.sh</include>
- </includes>
- <filtering>false</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-jar</id>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
- <resources>
- <resource>
- <directory>target</directory>
- <includes>
- <include>*.jar</include>
- </includes>
- <filtering>false</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ <plugin>
+ <groupId>com.github.kongchen</groupId>
+ <artifactId>swagger-maven-plugin</artifactId>
+ <version>3.1.3</version>
+ <configuration>
+ <apiSources>
+ <apiSource>
+ <locations>org.onap.pomba.contextbuilder.aai.service.rs</locations>
+ <basePath>/aaicontextbuilder</basePath>
+ <info>
+ <title>${project.artifactId} Service</title>
+ <version>${project.version}</version>
+ </info>
+ <swaggerDirectory>${swagger.directory}</swaggerDirectory>
+ </apiSource>
+ </apiSources>
+ </configuration>
+ <executions>
+ <execution>
+ <!-- <phase>compile</phase> -->
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-dockerfile</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals><!-- here the phase you need -->
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/docker</directory>
+ <includes>
+ <include>Dockerfile</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-properties</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage/config</outputDirectory>
+ <resources>
+ <resource>
+ <directory>config</directory>
+ <includes>
+ <include>*.properties</include>
+ <include>*.xml</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-script</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/docker</directory>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-jar</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
+ <resources>
+ <resource>
+ <directory>target</directory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/AAIConfiguration.java b/src/main/java/org/onap/pomba/contextbuilder/aai/AAIConfiguration.java
index 7befdc9..22f7b5e 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/AAIConfiguration.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/AAIConfiguration.java
@@ -56,10 +56,6 @@ public class AAIConfiguration {
private Integer readTimeout;
@Autowired
- @Value("${aai.serviceInstancePath}")
- private String serviceInstancePath;
-
- @Autowired
@Value("${http.userId}")
private String httpUserId;
@@ -99,10 +95,6 @@ public class AAIConfiguration {
}
- @Bean(name="aaiServiceInstancePath")
- public String getserviceInstancePathL() {
- return serviceInstancePath;
- }
@Value("${aai.searchNodeQuery}")
private String searchNodeQuery;
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/Vserver.java b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/Vserver.java
new file mode 100644
index 0000000..368dd90
--- /dev/null
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/Vserver.java
@@ -0,0 +1,203 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.pomba.contextbuilder.aai.datatype;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.onap.pomba.contextbuilder.aai.exception.AuditError;
+import org.onap.pomba.contextbuilder.aai.exception.AuditException;
+
+public class Vserver {
+
+ @SerializedName("vserver-id")
+ @Expose
+ private String vserverId;
+ @SerializedName("vserver-name")
+ @Expose
+ private String vserverName;
+ @SerializedName("vserver-name2")
+ @Expose
+ private String vserverName2;
+ @SerializedName("prov-status")
+ @Expose
+ private String provStatus;
+ @SerializedName("vserver-selflink")
+ @Expose
+ private String vserverSelflink;
+ @SerializedName("in-maint")
+ @Expose
+ private Boolean inMaint;
+ @SerializedName("is-closed-loop-disabled")
+ @Expose
+ private Boolean isClosedLoopDisabled;
+ @SerializedName("resource-version")
+ @Expose
+ private String resourceVersion;
+ @SerializedName("relationship-list")
+ @Expose
+ private RelationshipList relationshipList;
+
+ private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
+
+ public String toJson() {
+ return gson.toJson(this);
+ }
+
+ public static Vserver fromJson(String payload) throws AuditException {
+ try {
+ if (payload == null || payload.isEmpty()) {
+ throw new AuditException("Empty Json response");
+ }
+ return gson.fromJson(payload, Vserver.class);
+ } catch (Exception ex) {
+ throw new AuditException(AuditError.JSON_READER_PARSE_ERROR, ex);
+ }
+ }
+
+ /**
+ * No args constructor for use in serialization
+ *
+ */
+ public Vserver() {
+ }
+
+ /**
+ *
+ * @param relationshipList
+ * @param provStatus
+ * @param inMaint
+ * @param vserverName2
+ * @param resourceVersion
+ * @param vserverSelflink
+ * @param vserverName
+ * @param vserverId
+ * @param isClosedLoopDisabled
+ */
+ public Vserver(String vserverId, String vserverName, String vserverName2, String provStatus, String vserverSelflink, Boolean inMaint, Boolean isClosedLoopDisabled, String resourceVersion, RelationshipList relationshipList) {
+ super();
+ this.vserverId = vserverId;
+ this.vserverName = vserverName;
+ this.vserverName2 = vserverName2;
+ this.provStatus = provStatus;
+ this.vserverSelflink = vserverSelflink;
+ this.inMaint = inMaint;
+ this.isClosedLoopDisabled = isClosedLoopDisabled;
+ this.resourceVersion = resourceVersion;
+ this.relationshipList = relationshipList;
+ }
+
+ public String getVserverId() {
+ return vserverId;
+ }
+
+ public void setVserverId(String vserverId) {
+ this.vserverId = vserverId;
+ }
+
+ public String getVserverName() {
+ return vserverName;
+ }
+
+ public void setVserverName(String vserverName) {
+ this.vserverName = vserverName;
+ }
+
+ public String getVserverName2() {
+ return vserverName2;
+ }
+
+ public void setVserverName2(String vserverName2) {
+ this.vserverName2 = vserverName2;
+ }
+
+ public String getProvStatus() {
+ return provStatus;
+ }
+
+ public void setProvStatus(String provStatus) {
+ this.provStatus = provStatus;
+ }
+
+ public String getVserverSelflink() {
+ return vserverSelflink;
+ }
+
+ public void setVserverSelflink(String vserverSelflink) {
+ this.vserverSelflink = vserverSelflink;
+ }
+
+ public Boolean getInMaint() {
+ return inMaint;
+ }
+
+ public void setInMaint(Boolean inMaint) {
+ this.inMaint = inMaint;
+ }
+
+ public Boolean getIsClosedLoopDisabled() {
+ return isClosedLoopDisabled;
+ }
+
+ public void setIsClosedLoopDisabled(Boolean isClosedLoopDisabled) {
+ this.isClosedLoopDisabled = isClosedLoopDisabled;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("vserverId", vserverId).append("vserverName", vserverName).append("vserverName2", vserverName2).append("provStatus", provStatus).append("vserverSelflink", vserverSelflink).append("inMaint", inMaint).append("isClosedLoopDisabled", isClosedLoopDisabled).append("resourceVersion", resourceVersion).append("relationshipList", relationshipList).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(relationshipList).append(provStatus).append(inMaint).append(vserverName2).append(resourceVersion).append(vserverSelflink).append(vserverName).append(vserverId).append(isClosedLoopDisabled).toHashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof Vserver) == false) {
+ return false;
+ }
+ Vserver rhs = ((Vserver) other);
+ return new EqualsBuilder().append(relationshipList, rhs.relationshipList).append(provStatus, rhs.provStatus).append(inMaint, rhs.inMaint).append(vserverName2, rhs.vserverName2).append(resourceVersion, rhs.resourceVersion).append(vserverSelflink, rhs.vserverSelflink).append(vserverName, rhs.vserverName).append(vserverId, rhs.vserverId).append(isClosedLoopDisabled, rhs.isClosedLoopDisabled).isEquals();
+ }
+
+}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringService.java b/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringService.java
index aa28e2b..59ee36d 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringService.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringService.java
@@ -23,5 +23,5 @@ import org.onap.pomba.contextbuilder.aai.exception.AuditException;
public interface SpringService {
- public ModelContext getContext(String serviceInstanceId, String modelVersionId, String modelInvariantId, String serviceType, String customerId, String transactionId) throws AuditException;
+ public ModelContext getContext(String serviceInstanceId, String modelVersionId, String modelInvariantId, String transactionId) throws AuditException;
}
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringServiceImpl.java b/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringServiceImpl.java
index 2ec49f3..bce3a2e 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringServiceImpl.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/service/SpringServiceImpl.java
@@ -35,8 +35,7 @@ public class SpringServiceImpl implements SpringService {
private RestClient aaiClient;
@Autowired
private String aaiBaseUrl;
- @Autowired
- private String aaiServiceInstancePath;
+
@Autowired
private String aaiBasicAuthorization;
@Autowired
@@ -46,18 +45,16 @@ public class SpringServiceImpl implements SpringService {
// needed for instantiation
}
- @Override
- public ModelContext getContext(String serviceInstanceId, String modelVersionId, String modelInvariantId, String serviceType, String customerId, String tranId) throws AuditException {
+ public ModelContext getContext(String serviceInstanceId, String modelVersionId, String modelInvariantId, String tranId) throws AuditException {
- String url = "serviceInstanceId=" + serviceInstanceId + " modelVersion="+modelVersionId +
- " modelInvariantId="+ modelInvariantId + " serviceType="+serviceType + " customerId="+ customerId;
+ String url = "serviceInstanceId=" + serviceInstanceId + " modelVersion="+modelVersionId + " modelInvariantId="+ modelInvariantId ;
log.info(LogMessages.AAI_CONTEXT_BUILDER_URL, url);
ModelContext context = null;
// Retrieve the service instance information from AAI
try {
- context= RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, aaiServiceInstancePath, tranId, serviceInstanceId, modelVersionId, modelInvariantId, serviceType, customerId,aaiBasicAuthorization);
+ context= RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, tranId, serviceInstanceId, modelVersionId, modelInvariantId, aaiBasicAuthorization);
} catch (AuditException ae) {
throw ae;
} catch (Exception e) {
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/service/rs/RestService.java b/src/main/java/org/onap/pomba/contextbuilder/aai/service/rs/RestService.java
index dcc3382..22efa35 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/service/rs/RestService.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/service/rs/RestService.java
@@ -44,19 +44,17 @@ public interface RestService {
value = "Respond AAIContext Model Data",
notes = "Returns a JSON object which represents the AAIConetxt model data",
response = GenericResponse.class
- )
+ )
@ApiResponses(
value = {
@ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 404, message = "Service not available"),
@ApiResponse(code = 500, message = "Unexpected Runtime error")
- })
+ })
public Response getContext(@Context HttpHeaders headers,
@QueryParam("serviceInstanceId") String serviceInstanceId,
@QueryParam("modelVersionId") String modelVersionId,
- @QueryParam("modelInvariantId") String modelInvariantId,
- @QueryParam("serviceType") String serviceType,
- @QueryParam("customerId") String customerId
+ @QueryParam("modelInvariantId") String modelInvariantId
);
} \ No newline at end of file
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/service/rs/RestServiceImpl.java b/src/main/java/org/onap/pomba/contextbuilder/aai/service/rs/RestServiceImpl.java
index 6fc2c8a..824e251 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/service/rs/RestServiceImpl.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/service/rs/RestServiceImpl.java
@@ -43,10 +43,9 @@ public class RestServiceImpl implements RestService {
private String httpBasicAuthorization;
@Override
- public Response getContext(HttpHeaders headers, String serviceInstanceId, String modelVersionId, String modelInvariantId, String serviceType, String customerId) {
+ public Response getContext(HttpHeaders headers, String serviceInstanceId, String modelVersionId, String modelInvariantId) {
- String url = "serviceInstanceId=" + serviceInstanceId + " modelVersion="+modelVersionId +
- " modelInvariantId="+ modelInvariantId + " serviceType="+serviceType + " customerId="+ customerId;
+ String url = "serviceInstanceId=" + serviceInstanceId + " modelVersion="+modelVersionId + " modelInvariantId="+ modelInvariantId;
if(log.isDebugEnabled()) {
log.debug(LogMessages.AAI_CONTEXT_BUILDER_URL, url);
}
@@ -60,14 +59,14 @@ public class RestServiceImpl implements RestService {
try {
// Do some validation on Http headers and URL parameters
- RestUtil.validateBasicAuthorization(headers, httpBasicAuthorization);
+ RestUtil.validateBasicAuthorization(headers, httpBasicAuthorization);
RestUtil.validateHeader(headers);
- RestUtil.validateURL(serviceInstanceId, modelVersionId, modelInvariantId, serviceType, customerId);
+ RestUtil.validateURL(serviceInstanceId, modelVersionId, modelInvariantId);
// Keep the same transaction id for logging purpose
transactionId= RestUtil.extractTranIdHeader(headers);
- aaiContext = service.getContext(serviceInstanceId, modelVersionId, modelInvariantId, serviceType, customerId, transactionId);
+ aaiContext = service.getContext(serviceInstanceId, modelVersionId, modelInvariantId, transactionId);
if (aaiContext==null) {
// Return empty JSON
diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java b/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
index 905a8bc..60bbd61 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java
@@ -14,9 +14,7 @@
package org.onap.pomba.contextbuilder.aai.util;
-
import com.sun.jersey.core.util.MultivaluedMapImpl;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -35,21 +33,27 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.restclient.client.RestClient;
+import org.onap.pomba.common.datatypes.Attribute;
+import org.onap.pomba.common.datatypes.DataQuality;
import org.onap.pomba.common.datatypes.ModelContext;
import org.onap.pomba.common.datatypes.Service;
import org.onap.pomba.common.datatypes.VF;
import org.onap.pomba.common.datatypes.VFModule;
+import org.onap.pomba.common.datatypes.VM;
import org.onap.pomba.common.datatypes.VNFC;
import org.onap.pomba.contextbuilder.aai.common.LogMessages;
+import org.onap.pomba.contextbuilder.aai.datatype.Relationship;
+import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList;
import org.onap.pomba.contextbuilder.aai.datatype.ServiceInstance;
import org.onap.pomba.contextbuilder.aai.datatype.VfModule;
import org.onap.pomba.contextbuilder.aai.datatype.VnfInstance;
import org.onap.pomba.contextbuilder.aai.datatype.VnfcInstance;
+import org.onap.pomba.contextbuilder.aai.datatype.Vserver;
import org.onap.pomba.contextbuilder.aai.exception.AuditError;
import org.onap.pomba.contextbuilder.aai.exception.AuditException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
+
public class RestUtil {
@@ -60,8 +64,7 @@ public class RestUtil {
private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
private static final String MODEL_VERSION_ID = "modelVersionId";
private static final String MODEL_INVARIANT_ID = "modelInvariantId";
- private static final String CUSTOMER_ID = "customerId";
- private static final String SERVICE_TYPE = "serviceType";
+
// HTTP headers
private static final String TRANSACTION_ID = "X-TransactionId";
@@ -70,10 +73,16 @@ public class RestUtil {
private static final String APP_NAME = "aaiCtxBuilder";
- // Service Catalog
+ // Service Catalog - "related-to"
private static final String CATALOG_GENERIC_VNF = "generic-vnf";
private static final String CATALOG_VNFC = "vnfc";
private static final String CATALOG_SERVICE_INSTANCE = "service-instance";
+ private static final String CATALOG_VSERVER = "vserver";
+ private static final String CATALOG_IMAGE = "image";
+ private static final String CATALOG_PSERVER = "pserver";
+ private static final String VF_MODULES = "vf-modules";
+ private static final String VF_MODULE = "vf-module";
+
// Relationship Json Path
private static final String RELATIONSHIP_LIST = "relationship-list";
@@ -95,8 +104,8 @@ public class RestUtil {
*
* @throws AuditException if there is missing parameter
*/
- public static void validateURL(String serviceInstanceId, String modelVersionId, String modelInvariantId,
- String serviceType, String customerId) throws AuditException {
+ public static void validateURL(String serviceInstanceId, String modelVersionId, String modelInvariantId)
+ throws AuditException {
if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
throw new AuditException(AuditError.INVALID_REQUEST_URL_MISSING_PARAMETER + SERVICE_INSTANCE_ID,
@@ -112,18 +121,10 @@ public class RestUtil {
Status.BAD_REQUEST);
}
- // serviceType
- if (serviceType == null || serviceType.isEmpty()) {
- throw new AuditException(AuditError.INVALID_REQUEST_URL_MISSING_PARAMETER + SERVICE_TYPE, Status.BAD_REQUEST);
- }
- // customerId
- if (customerId == null || customerId.isEmpty()) {
- throw new AuditException(AuditError.INVALID_REQUEST_URL_MISSING_PARAMETER + CUSTOMER_ID, Status.BAD_REQUEST);
- }
}
public static void validateBasicAuthorization(HttpHeaders headers, String basicAuthorization) throws AuditException {
- String authorization = null;
+ String authorization = null;
// validation on HTTP Authorization Header
authorization = headers.getRequestHeaders().getFirst(AUTHORIZATION);
@@ -166,25 +167,25 @@ public class RestUtil {
}
/*
- * Trigger external API call to AAI to retrieve Service Instance data (i.e. genericVNF and VNFC)
+ * Trigger external API call to AAI to collect the data in order to transform to common model
+ *
*/
- public static ModelContext retrieveAAIModelData(RestClient aaiClient, String baseURL, String aaiPathToSearchNodeQuery, String aaiServiceInstancePath,
- String transactionId, String serviceInstanceId, String modelVersionId, String modelInvariantId,
- String serviceType, String customerId, String aaiBasicAuthorization) throws AuditException {
+ public static ModelContext retrieveAAIModelData(RestClient aaiClient, String baseURL, String aaiPathToSearchNodeQuery,
+ String transactionId, String serviceInstanceId, String modelVersionId, String modelInvariantId, String aaiBasicAuthorization) throws AuditException {
String serviceInstancePayload = null;
String genericVNFPayload = null;
- String vnfcPayload = null;
- // Follow two variables for transform purpose
List<VnfInstance> vnfLst = new ArrayList<VnfInstance>(); // List of the VNF POJO object
- Map<String, List<VnfcInstance>> vnfMap = new HashMap<String, List<VnfcInstance>>(); // MAP the vnf-id as the
- // key, and list of the vNFC
- // pojo object
+ //Map to track multiple vnfc under the Gerneric VNF id. The key = vnf-id. The value = list of vnfc instance
+ Map<String, List<VnfcInstance>> vnfcMap = new HashMap<String, List<VnfcInstance>>();
+
+ //Map to track the relationship between vnf->vfmodule->verver
+ Map<String, Map<String, List<Vserver>>> vnf_vfmodule_vserver_Map = new HashMap<String, Map<String, List<Vserver>>>();
+
// Obtain resource-link based on resource-type = service-Instance
String resourceLink = obtainResouceLinkBasedOnServiceInstanceFromAAI(aaiClient, baseURL, aaiPathToSearchNodeQuery, serviceInstanceId, transactionId, aaiBasicAuthorization);
+ String url = baseURL + resourceLink;
- String url = baseURL
- + generateServiceInstanceURL(aaiServiceInstancePath, customerId, serviceType, serviceInstanceId);
// Response from service instance API call
serviceInstancePayload =
getResource(aaiClient, url, aaiBasicAuthorization, transactionId, MediaType.valueOf(MediaType.APPLICATION_JSON));
@@ -200,7 +201,6 @@ public class RestUtil {
log.info(LogMessages.NUMBER_OF_API_CALLS, "genericVNF", genericVNFLinkLst.size());
log.info(LogMessages.API_CALL_LIST, "genericVNF", printOutAPIList(genericVNFLinkLst));
-
for (String genericVNFLink : genericVNFLinkLst) {
// With latest AAI development, in order to retrieve the both generic VNF + vf_module, we can use
// one API call but with depth=2
@@ -212,50 +212,121 @@ public class RestUtil {
if (isEmptyJson(genericVNFPayload)) {
log.info(LogMessages.NOT_FOUND, "GenericVNF with url ", genericVNFLink);
} else {
-
// Logic to Create the Generic VNF Instance POJO object
VnfInstance vnfInstance = VnfInstance.fromJson(genericVNFPayload);
vnfLst.add(vnfInstance);
- List<String> vnfcLinkLst = extractRelatedLink(genericVNFPayload, CATALOG_VNFC);
- log.info(LogMessages.NUMBER_OF_API_CALLS, "vnfc", vnfcLinkLst.size());
- log.info(LogMessages.API_CALL_LIST, "vnfc", printOutAPIList(vnfcLinkLst));
-
- List<VnfcInstance> vnfcLst = new ArrayList<VnfcInstance>();
- for (String vnfcLink : vnfcLinkLst) {
- String vnfcURL = baseURL + vnfcLink;
- vnfcPayload = getResource(aaiClient, vnfcURL, aaiBasicAuthorization, transactionId,
- MediaType.valueOf(MediaType.APPLICATION_XML));
-
- if (isEmptyJson(vnfcPayload)) {
- log.info(LogMessages.NOT_FOUND, "VNFC with url", vnfcLink);
- } else {
- // Logic to Create the VNFC POJO object
- VnfcInstance vnfcInstance = VnfcInstance.fromJson(vnfcPayload);
- vnfcLst.add(vnfcInstance);
- }
- }
+ // Build the vnf_vnfc relationship map
+ vnfcMap = buildVnfcMap(genericVNFPayload, aaiClient, baseURL, transactionId, aaiBasicAuthorization );
+
+ // Build vnf_vfmodule_vserver relationship map
+ vnf_vfmodule_vserver_Map= buildVfmoduleVserverMap(genericVNFPayload, aaiClient, baseURL, transactionId, aaiBasicAuthorization);
- // Assume the vnf-id is unique as a key
- vnfMap.put(vnfInstance.getVnfId(), vnfcLst);
}
}
// Transform to common model and return
- return transform(ServiceInstance.fromJson(serviceInstancePayload), vnfLst, vnfMap);
+ return transform(ServiceInstance.fromJson(serviceInstancePayload), vnfLst, vnfcMap, vnf_vfmodule_vserver_Map);
}
+ /*
+ * The map is to track the relationship of vnf-id with multiple vnfc relationship
+ */
+ private static Map<String, List<VnfcInstance>> buildVnfcMap(String genericVNFPayload, RestClient aaiClient, String baseURL,
+ String transactionId, String aaiBasicAuthorization) throws AuditException {
+
+ String vnfcPayload = null;
+ Map<String, List<VnfcInstance>> vnfcMap = new HashMap<String, List<VnfcInstance>>();
+
+ List<String> vnfcLinkLst = extractRelatedLink(genericVNFPayload, CATALOG_VNFC);
+ log.info(LogMessages.NUMBER_OF_API_CALLS, "vnfc", vnfcLinkLst.size());
+ log.info(LogMessages.API_CALL_LIST, "vnfc", printOutAPIList(vnfcLinkLst));
+
+ List<VnfcInstance> vnfcLst = new ArrayList<VnfcInstance>();
+ for (String vnfcLink : vnfcLinkLst) {
+ String vnfcURL = baseURL + vnfcLink;
+ vnfcPayload = getResource(aaiClient, vnfcURL, aaiBasicAuthorization, transactionId,
+ MediaType.valueOf(MediaType.APPLICATION_XML));
+
+ if (isEmptyJson(vnfcPayload)) {
+ log.info(LogMessages.NOT_FOUND, "VNFC with url", vnfcLink);
+ } else {
+ // Logic to Create the VNFC POJO object
+ VnfcInstance vnfcInstance = VnfcInstance.fromJson(vnfcPayload);
+ vnfcLst.add(vnfcInstance);
+ }
+ }
+ // Assume the vnf-id is unique as a key
+ vnfcMap.put(getVnfId(genericVNFPayload), vnfcLst);
+
+ return vnfcMap;
+ }
+
+ /*
+ * This is a two layer map to track the relationship between vnf->vfmodule->verver
+ *
+ * The Map<String, List<Vserver> is to track multiple vserver under the vfModule.
+ * Key: combination of the model_version_id and model_invariant_id.
+ * Value: list of Vserver
+ *
+ * The Map<String, Map<String, List<Vserver>>> key: vnf-id
+ */
+ private static Map<String, Map<String, List<Vserver>>> buildVfmoduleVserverMap(String genericVNFPayload, RestClient aaiClient, String baseURL, String transactionId, String aaiBasicAuthorization) throws AuditException {
+
+ Map<String, Map<String, List<Vserver>>> vnf_vfmodule_vserver_Map = new HashMap<String, Map<String, List<Vserver>>>();
+
+ Map<String, List<Vserver>> vServerMap = new HashMap<String, List<Vserver>>();
+
+ Map<String, List<String>> vServerRelatedLinkMap = extractRelatedLinkFromVfmodule(genericVNFPayload, CATALOG_VSERVER);
+ String vnfId= getVnfId(genericVNFPayload);
+ String vserverPayload = null;
+
+ for(Map.Entry<String, List<String>> entry : vServerRelatedLinkMap.entrySet()) {
+
+ List<String> vserverLinkLst = entry.getValue();
+ log.info(LogMessages.NUMBER_OF_API_CALLS, "vserver", vserverLinkLst.size());
+ log.info(LogMessages.API_CALL_LIST, "vserver", printOutAPIList(vserverLinkLst));
+
+ List<Vserver> vserverLst = new ArrayList<Vserver>();
+ for (String vserverLink : vserverLinkLst) {
+ String vserverURL = baseURL + vserverLink;
+ vserverPayload = getResource(aaiClient, vserverURL, aaiBasicAuthorization, transactionId,
+ MediaType.valueOf(MediaType.APPLICATION_XML));
+
+ if (isEmptyJson(vserverPayload)) {
+ log.info(LogMessages.NOT_FOUND, "VSERVER with url", vserverURL);
+ } else {
+ // Logic to Create the Vserver POJO object
+ Vserver vserver = Vserver.fromJson(vserverPayload);
+ vserverLst.add(vserver);
+ }
+ }
+
+ vServerMap.put(entry.getKey(), vserverLst);
+ }
+
+ vnf_vfmodule_vserver_Map.put(vnfId, vServerMap);
+
+ return vnf_vfmodule_vserver_Map;
+ }
+
+
+ private static String getVnfId(String genericVNFPayload) throws AuditException {
+
+ VnfInstance vnfInstance = VnfInstance.fromJson(genericVNFPayload);
+ return vnfInstance.getVnfId();
+ }
/*
* Transform AAI Representation to Common Model
*/
private static ModelContext transform(ServiceInstance svcInstance, List<VnfInstance> vnfLst,
- Map<String, List<VnfcInstance>> vnfMap) {
+ Map<String, List<VnfcInstance>> vnfcMap, Map<String, Map<String, List<Vserver>>> vnf_vfmodule_vserver_Map) {
ModelContext context = new ModelContext();
Service service = new Service();
service.setInvariantUuid(svcInstance.getModelInvariantId());
service.setName(svcInstance.getServiceInstanceName());
service.setUuid(svcInstance.getModelVersionId());
-
+ service.setDataQuality(DataQuality.ok());
List<VF> vfLst = new ArrayList<VF>();
for (VnfInstance vnf : vnfLst) {
@@ -264,12 +335,13 @@ public class RestUtil {
vf.setName(vnf.getVnfName());
vf.setUuid(vnf.getModelVersionId());
vf.setType(vnf.getVnfType());
- vf.setNfNamingCode(vnf.getNfNamingCode());
+ vf.setDataQuality(DataQuality.ok());
- String key = vnf.getVnfId();
- List<VNFC> vnfcLst = new ArrayList<VNFC>();
+ String key = vnf.getVnfId(); // generic vnf-id (top level of the key)
- for (Map.Entry<String, List<VnfcInstance>> entry : vnfMap.entrySet()) {
+ // ---------------- Handle VNFC data
+ List<VNFC> vnfcLst = new ArrayList<VNFC>();
+ for (Map.Entry<String, List<VnfcInstance>> entry : vnfcMap.entrySet()) {
if (key.equals(entry.getKey())) {
List<VnfcInstance> vnfcInstanceLst = entry.getValue();
@@ -278,55 +350,141 @@ public class RestUtil {
VNFC vnfcModel = new VNFC();
vnfcModel.setInvariantUuid(vnfc.getModelInvariantId());
vnfcModel.setName(vnfc.getVnfcName());
- vnfcModel.setNfcNamingCode(vnfc.getNfcNamingCode());
vnfcModel.setUuid(vnfc.getModelVersionId());
vnfcLst.add(vnfcModel);
}
}
}
+ vf.setVnfcs(vnfcLst);
- vf.setVnfc(vnfcLst);
- // Add the vfModule
- List<VFModule> vfModuleLst = new ArrayList<VFModule>();
- if (vnf.getVfModules() != null) {
- ConcurrentMap<String, AtomicInteger> vnfModulemap =
- buildMaxInstanceMap(vnf.getVfModules().getVfModule());
+ // --------------- Handle the vfModule
+ //Map to calculate the Vf Module MaxInstance.
+ ConcurrentMap<String, AtomicInteger> maxInstanceMap =
+ buildMaxInstanceMap(vnf.getVfModules().getVfModule());
- for (Map.Entry<String, AtomicInteger> entry : vnfModulemap.entrySet()) {
- String[] s = entry.getKey().split("\\" + DELIMITER);
+ List<VFModule> vfModuleLst = new ArrayList<VFModule>();
+ for ( Map.Entry<String, Map<String, List<Vserver>>> entry: vnf_vfmodule_vserver_Map.entrySet() ) {
+ // find the vnf-id
+ if (key.equals(entry.getKey())) {
+
+ Map<String, List<Vserver>> vfmodule_vserver_map= entry.getValue();
+
+ for ( Map.Entry<String, List<Vserver>> vfmoduleEntry: vfmodule_vserver_map.entrySet() ){
+ // The key is modelversionId$modelInvariantid
+ String[] s = vfmoduleEntry.getKey().split("\\" + DELIMITER);
+ String modelVersionId = s[0];
+ String modelInvariantId = s[1];
+
+ VFModule vfModule = new VFModule();
+ vfModule.setUuid(modelVersionId);
+ vfModule.setInvariantUuid(modelInvariantId);
+ vfModule.setMaxInstances(getMaxInstance(vfmoduleEntry.getKey(), maxInstanceMap));
+ vfModule.setDataQuality(DataQuality.ok());
+
+ List<Vserver> vserverList = vfmoduleEntry.getValue();
+
+ // Handle VM
+ List<VM> vmList = new ArrayList<VM>();
+ for (Vserver vserver: vserverList) {
+
+ List<Attribute> attributeList = new ArrayList<Attribute>();
+
+ // Iterate through the ENUM Attribute list
+ for (Attribute.Name name: Attribute.Name.values()) {
+ if (name.toString().equals("lockedBoolean")) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.lockedBoolean);
+ att.setValue(String.valueOf(vserver.getInMaint()));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals("hostName")) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.hostName);
+ att.setValue(getVserverAttribute(vserver, CATALOG_PSERVER));
+ attributeList.add(att);
+ }
+
+ if (name.toString().equals("imageId")) {
+ Attribute att = new Attribute();
+ att.setDataQuality(DataQuality.ok());
+ att.setName(Attribute.Name.imageId);
+ att.setValue(getVserverAttribute(vserver, CATALOG_IMAGE));
+ attributeList.add(att);
+ }
+ }
+ VM vm = new VM();
+ vm.setUuid(vserver.getVserverId());
+ vm.setName(vserver.getVserverName());
+ vm.setAttributes(attributeList);
+ vmList.add(vm);
+ }
+ vfModule.setVms(vmList);
+ vfModuleLst.add(vfModule);
+ }
- String modelVersionId = s[0];
- String modelInvariantId = s[1];
- VFModule vfModule = new VFModule();
- vfModule.setUuid(modelVersionId);
- vfModule.setInvariantUuid(modelInvariantId);
- vfModule.setMaxInstances(entry.getValue().intValue());
- vfModuleLst.add(vfModule);
}
}
- vf.setVfModules(vfModuleLst);
+ vf.setVfModules(vfModuleLst);
vfLst.add(vf);
} // done the vnfInstance
context.setService(service);
- context.setVf(vfLst);
+ context.setVfs(vfLst);
return context;
}
+ /*
+ * Return the Vserver Attribute value by looking through the relationship. i.e. if "related-to" is "pserver", we will get
+ * the value of the attribute "hostname" from the last substring of the "related-link"
+ * {
+ * "related-to": "pserver",
+ * "related-link": "/aai/v11/cloud-infrastructure/pservers/pserver/rdm5r10c008.rdm5a.cci.att.com",
+ * "relationship-data": [ {
+ * "relationship-key": "pserver.hostname",
+ * "relationship-value": "rdm5r10c008.rdm5a.cci.att.com"
+ * }],
+ * "related-to-property": [{"property-key": "pserver.pserver-name2"}]
+ * },
+ *
+ */
+ private static String getVserverAttribute(Vserver vserver, String key) {
+ RelationshipList lst = vserver.getRelationshipList();
+ if (lst != null) {
+ List<Relationship> relations = lst.getRelationship();
+ for (Relationship re: relations) {
+ if (re.getRelatedTo().equals(key)) {
+ return extractAttValue(re.getRelatedLink());
+ }
+ }
+ }
+ return null;
+ }
+
+
+
+ /*
+ * Get the last substring from the related-link
+ * For example the value of the attribute "hostname" will be "rdm5r10c008.rdm5a.cci.att.com"
+ * "related-to": "pserver",
+ * "related-link": "/aai/v11/cloud-infrastructure/pservers/pserver/rdm5r10c008.rdm5a.cci.att.com",
+ */
+ private static String extractAttValue(String relatedLink) {
+ return relatedLink.substring(relatedLink.lastIndexOf("/")+1);
+ }
/*
* Build the map with key (model_version_id and model_invariant_id), and with the max occurrences of
* the value in the map
*
- * @param vfModuleList
- *
- * @return
*/
private static ConcurrentMap<String, AtomicInteger> buildMaxInstanceMap(List<VfModule> vfModuleList) {
@@ -348,6 +506,20 @@ public class RestUtil {
}
+ /*
+ * Return the occurrence of the VfModule complex key: (model-version-id)+(model-invariant-id)
+ */
+ private static int getMaxInstance(String key, ConcurrentMap<String, AtomicInteger> maxInstanceMap) {
+
+ for (Map.Entry<String, AtomicInteger> entry : maxInstanceMap.entrySet()) {
+
+ if (entry.getKey().equals(key)) {
+ return entry.getValue().intValue();
+ }
+
+ }
+ return 0;
+ }
public static boolean isEmptyJson(String serviceInstancePayload) {
@@ -355,7 +527,9 @@ public class RestUtil {
return (serviceInstancePayload.equals(EMPTY_JSON_STRING));
}
-
+ /*
+ * Debug purpose - Display the related-link list
+ */
private static String printOutAPIList(List<String> relatedLinkLst) {
StringBuilder builder = new StringBuilder();
@@ -383,7 +557,7 @@ public class RestUtil {
JSONObject jsonPayload = new JSONObject(payload);
JSONArray relationships = null;
List<String> relatedLinkList = new ArrayList<String>();
- log.info("Fetching the vnfc related link");
+ log.debug("Fetching the related link");
try {
JSONObject relationshipList = jsonPayload.getJSONObject(RELATIONSHIP_LIST);
@@ -417,9 +591,67 @@ public class RestUtil {
return relatedLinkList;
}
+ /*
+ * Return the Map with key: Vfmodule->model-version-id + Vfmoduel->model-invariant-id
+ * with value: list of the related-link based on the catalog
+ * The catalog can be "vserver" or "l3-network" based on common model requirement.
+ */
+ private static Map<String, List<String>> extractRelatedLinkFromVfmodule(String payload, String catalog) throws AuditException {
+
+ Map<String, List<String>> vServerRelatedLinkMap = new HashMap<String, List<String>>();
+
+ JSONObject jsonPayload = new JSONObject(payload);
+ JSONArray vfmoduleArray = null;
+ JSONArray relationships = null;
+
+ try {
+ log.debug("Fetching the Vf-module");
+ JSONObject vfmodules = jsonPayload.getJSONObject(VF_MODULES);
+ if (vfmodules != null) {
+ vfmoduleArray = vfmodules.getJSONArray(VF_MODULE);
+ }
+
+ if (vfmoduleArray != null && vfmoduleArray.length() > 0) {
+ for (int i = 0; i < vfmoduleArray.length(); i++) {
+ List<String> relatedLinkList = new ArrayList<String>();
+ JSONObject obj = vfmoduleArray.optJSONObject(i);
+ String key = (String)obj.get("model-version-id") + DELIMITER + (String)obj.get("model-invariant-id");
+
+ log.debug("Fetching the relationship");
+ JSONObject relationshipList = obj.getJSONObject(RELATIONSHIP_LIST);
+ if (relationshipList != null) {
+ relationships = relationshipList.getJSONArray(RELATIONSHIP);
+ }
+ if (relationships != null && relationships.length() > 0) {
+ for (int j = 0; j < relationships.length(); j++) {
+ Object relatedToObj = null;
+ Object relatedLinkObj = null;
+
+ JSONObject obj2 = relationships.optJSONObject(j);
+ relatedToObj = obj2.get(JSON_ATT_RELATED_TO);
+
+ if (relatedToObj.toString().equals(catalog)) {
+ relatedLinkObj = obj2.get(JSON_ATT_RELATED_LINK);
+ if (relatedLinkObj != null) {
+ relatedLinkList.add(relatedLinkObj.toString());
+ }
+ }
+ } //relationship
+ }
+
+ vServerRelatedLinkMap.put(key, relatedLinkList);
+ } //vf-module
+ }
+
+ } catch (Exception e) {
+ log.error(e.getMessage());
+ throw new AuditException(AuditError.JSON_READER_PARSE_ERROR + " " + e.getMessage());
+ }
+
+ return vServerRelatedLinkMap;
+ }
- @SuppressWarnings("unchecked")
private static Map<String, List<String>> buildHeaders(String aaiBasicAuthorization, String transactionId) {
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
headers.put(TRANSACTION_ID, Collections.singletonList(transactionId));
@@ -446,11 +678,6 @@ public class RestUtil {
}
- private static String generateServiceInstanceURL(String siPath, String customerId, String serviceType,
- String serviceInstanceId) {
- return MessageFormat.format(siPath, customerId, serviceType, serviceInstanceId);
- }
-
public static String obtainResouceLinkBasedOnServiceInstanceFromAAI(RestClient aaiClient, String baseURL, String aaiPathToSearchNodeQuery, String serviceInstanceId,
String transactionId, String aaiBasicAuthorization) throws AuditException {
@@ -467,7 +694,7 @@ public class RestUtil {
return extractResourceLinkBasedOnResourceType(customerInfoString, CATALOG_SERVICE_INSTANCE);
}
- private static String generateGetCustomerInfoUrl (String baseURL, String aaiPathToSearchNodeQuery ,String serviceInstanceId) {
+ private static String generateGetCustomerInfoUrl (String baseURL, String aaiPathToSearchNodeQuery,String serviceInstanceId) {
return baseURL + aaiPathToSearchNodeQuery + serviceInstanceId;
}
diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java
index f8991c1..8b3fe63 100644
--- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java
+++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java
@@ -61,80 +61,54 @@ public class RestUtilTest {
@Rule
public WireMockRule aaiEnricherRule = new WireMockRule(wireMockConfig().port(9808));
- @Test
- public void testValidateURL() {
- // Missing ServiceInstanceId or it is null
- try {
- RestUtil.validateURL("", "modelVersionId", "modelInvariantId", "serviceType", "customerId");
- } catch (AuditException e) {
- assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: serviceInstanceId"));
- }
-
- try {
- RestUtil.validateURL(null, "modelVersionId", "modelInvariantId", "serviceType", "customerId");
- } catch (AuditException e) {
- assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: serviceInstanceId"));
- }
-
- // Missing ModelVersionId or it is null
- try {
- RestUtil.validateURL("serviceInstanceId", "", "modelInvariantId", "serviceType", "customerId");
- } catch (AuditException e) {
- assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: modelVersionId"));
- }
-
- try {
- RestUtil.validateURL("serviceInstanceId", null, "modelInvariantId", "serviceType", "customerId");
- } catch (AuditException e) {
- assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: modelVersionId"));
- }
-
- // Missing ModelInvariantId or it is null
- try {
- RestUtil.validateURL("serviceInstanceId", "modelVersionId", "", "serviceType", "customerId");
- } catch (AuditException e) {
- assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: modelInvariantId"));
- }
-
- try {
- RestUtil.validateURL("serviceInstanceId", "modelVersionId", null, "serviceType", "customerId");
- } catch (AuditException e) {
- assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: modelInvariantId"));
- }
-
- // Missing ServiceType or it is null
- try {
- RestUtil.validateURL("serviceInstanceId", "modelVersionId", "modelInvariantId", "", "customerId");
- } catch (AuditException e) {
- assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: serviceType"));
- }
-
- try {
- RestUtil.validateURL("serviceInstanceId", "modelVersionId", "modelInvariantId", null, "customerId");
- } catch (AuditException e) {
- assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: serviceType"));
- }
-
- // Missing CustomerId or it is null
- try {
- RestUtil.validateURL("serviceInstanceId", "modelVersionId", "modelInvariantId", "serviceType", "");
- } catch (AuditException e) {
- assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: customerId"));
- }
-
-
- try {
- RestUtil.validateURL("serviceInstanceId", "modelVersionId", "modelInvariantId", "serviceType", null);
- } catch (AuditException e) {
- assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: customerId"));
- }
- }
-
- @Test
- public void testIsEmptyJson() {
- assertTrue(RestUtil.isEmptyJson("{}"));
- assertTrue(!RestUtil.isEmptyJson("{Not Empty}"));
- }
+ @Test
+ public void testValidateURL() {
+ // Missing ServiceInstanceId or it is null
+ try {
+ RestUtil.validateURL("", "modelVersionId", "modelInvariantId");
+ } catch (AuditException e) {
+ assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: serviceInstanceId"));
+ }
+
+ try {
+ RestUtil.validateURL(null, "modelVersionId", "modelInvariantId");
+ } catch (AuditException e) {
+ assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: serviceInstanceId"));
+ }
+
+ // Missing ModelVersionId or it is null
+ try {
+ RestUtil.validateURL("serviceInstanceId", "", "modelInvariantId");
+ } catch (AuditException e) {
+ assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: modelVersionId"));
+ }
+
+ try {
+ RestUtil.validateURL("serviceInstanceId", null, "modelInvariantId");
+ } catch (AuditException e) {
+ assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: modelVersionId"));
+ }
+
+ // Missing ModelInvariantId or it is null
+ try {
+ RestUtil.validateURL("serviceInstanceId", "modelVersionId", "");
+ } catch (AuditException e) {
+ assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: modelInvariantId"));
+ }
+
+ try {
+ RestUtil.validateURL("serviceInstanceId", "modelVersionId", null);
+ } catch (AuditException e) {
+ assertTrue(e.getMessage().contains("Invalid request URL, missing parameter: modelInvariantId"));
+ }
+
+ }
+
+ @Test
+ public void testIsEmptyJson() {
+ assertTrue(RestUtil.isEmptyJson("{}"));
+ assertTrue(!RestUtil.isEmptyJson("{Not Empty}"));
+ }
@Test
public void testObtainResouceLinkBasedOnServiceInstanceFromAAI() throws Exception {