aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-nssmf-adapter
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-nssmf-adapter')
-rw-r--r--adapters/mso-nssmf-adapter/pom.xml149
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java32
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/RequestDbConfig.java68
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/WebSecurityConfig.java37
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java66
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientPropertiesImpl.java69
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientProvider.java34
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java32
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java66
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java63
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenRequest.java54
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java44
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java41
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java42
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java205
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java94
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java541
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java92
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java307
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java32
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java94
-rw-r--r--adapters/mso-nssmf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties1
-rw-r--r--adapters/mso-nssmf-adapter/src/main/resources/application.yaml61
-rw-r--r--adapters/mso-nssmf-adapter/src/main/resources/nssmf.jksbin0 -> 1386 bytes
-rw-r--r--adapters/mso-nssmf-adapter/src/main/resources/nssmf.p12bin0 -> 1616 bytes
-rw-r--r--adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.jksbin0 -> 1386 bytes
-rw-r--r--adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.p12bin0 -> 1616 bytes
-rw-r--r--adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java392
28 files changed, 2616 insertions, 0 deletions
diff --git a/adapters/mso-nssmf-adapter/pom.xml b/adapters/mso-nssmf-adapter/pom.xml
new file mode 100644
index 0000000000..b6b52ce7c5
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/pom.xml
@@ -0,0 +1,149 @@
+<!--
+ ~*
+ ~============LICENSE_START=======================================================
+ ~* ONAP - SO
+ ~*================================================================================
+ ~* Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ ~*================================================================================
+ ~* 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=========================================================
+ ~*/
+ -->
+
+<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>
+ <parent>
+ <groupId>org.onap.so</groupId>
+ <artifactId>adapters</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>mso-nssmf-adapter</artifactId>
+ <packaging>jar</packaging>
+ <name>mso-nssmf-adapter</name>
+ <description>Web service endpoint for nssmf operations</description>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${springboot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <mainClass>org.onap.so.adapters.nssmf.MSONssmfApplication</mainClass>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</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-jdbc</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jdbc</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring-boot-starter-jaxrs</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>mso-requests-db</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>mso-requests-db-repositories</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.vorburger.mariaDB4j</groupId>
+ <artifactId>mariaDB4j</artifactId>
+ <version>2.2.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-configuration-processor</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>okhttp</artifactId>
+ <version>3.14.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.18.2</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java
new file mode 100644
index 0000000000..cd011e6437
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication(scanBasePackages = {"org.onap.so"})
+public class MSONssmfApplication {
+
+ public static void main(String... args) {
+ SpringApplication.run(MSONssmfApplication.class, args);
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/RequestDbConfig.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/RequestDbConfig.java
new file mode 100644
index 0000000000..484f7624aa
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/RequestDbConfig.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf;
+
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Profile;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@Profile({"!test"})
+@Configuration
+@EnableTransactionManagement
+@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory",
+ transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"})
+public class RequestDbConfig {
+
+ @Primary
+ @Bean(name = "requestDataSource")
+ @ConfigurationProperties(prefix = "spring.datasource")
+ public DataSource dataSource() {
+ return DataSourceBuilder.create().build();
+ }
+
+ @Primary
+ @Bean(name = "requestEntityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
+ @Qualifier("requestDataSource") DataSource dataSource) {
+ return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB")
+ .build();
+ }
+
+ @Primary
+ @Bean(name = "requestTransactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/WebSecurityConfig.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/WebSecurityConfig.java
new file mode 100644
index 0000000000..1522ca9c6d
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/WebSecurityConfig.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+
+@EnableWebSecurity
+@Configuration
+public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.csrf().disable();
+ }
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java
new file mode 100644
index 0000000000..f63ba356a1
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.exceptions;
+
+import org.onap.so.adapters.nssmf.model.ErrorResponse;
+import org.springframework.http.ResponseEntity;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public class ApplicationException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private int errorCode;
+
+ private String errorMsg;
+
+ public ApplicationException(int errorCode, String errorMsg) {
+ this.errorCode = errorCode;
+ this.errorMsg = errorMsg;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorMsg() {
+ return errorMsg;
+ }
+
+ public void setErrorMsg(String errorMsg) {
+ this.errorMsg = errorMsg;
+ }
+
+ public ResponseEntity buildErrorResponse() {
+ String message;
+ try {
+ ErrorResponse err = new ErrorResponse(errorCode, errorMsg);
+ message = marshal(err);
+ } catch (ApplicationException e) {
+ return ResponseEntity.status(500).body("Internal Server Error");
+ }
+ return ResponseEntity.status(errorCode).body(message);
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientPropertiesImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientPropertiesImpl.java
new file mode 100644
index 0000000000..3333c64cd8
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientPropertiesImpl.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.extclients.aai;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.onap.so.client.aai.AAIProperties;
+import org.onap.so.client.aai.AAIVersion;
+import org.onap.so.spring.SpringContextHelper;
+import org.springframework.context.ApplicationContext;
+
+public class AaiClientPropertiesImpl implements AAIProperties {
+
+ private final String endpoint;
+
+ private final String encryptedBasicAuth;
+
+ private final String encrytptionKey;
+
+ public AaiClientPropertiesImpl() {
+ final ApplicationContext context = SpringContextHelper.getAppContext();
+ this.endpoint = context.getEnvironment().getProperty("aai.endpoint");
+ this.encryptedBasicAuth = context.getEnvironment().getProperty("aai.auth");
+ this.encrytptionKey = context.getEnvironment().getProperty("mso.key");
+ }
+
+ @Override
+ public AAIVersion getDefaultVersion() {
+ return AAIVersion.LATEST;
+ }
+
+ @Override
+ public String getAuth() {
+ return encryptedBasicAuth;
+ }
+
+ @Override
+ public String getKey() {
+ return encrytptionKey;
+ }
+
+ @Override
+ public URL getEndpoint() throws MalformedURLException {
+ return new URL(endpoint);
+ }
+
+ @Override
+ public String getSystemName() {
+ return "MSO";
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientProvider.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientProvider.java
new file mode 100644
index 0000000000..48e3ef1666
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientProvider.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.extclients.aai;
+
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class AaiClientProvider {
+
+ @Bean
+ public AAIResourcesClient getAaiClient() {
+ return new AAIResourcesClient();
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java
new file mode 100644
index 0000000000..c737ba6440
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.extclients.aai;
+
+import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.EsrThirdpartySdncList;
+
+public interface AaiServiceProvider {
+
+ EsrThirdpartySdncList invokeGetThirdPartySdncList();
+
+ EsrSystemInfoList invokeGetThirdPartySdncEsrSystemInfo(String sdncId);
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java
new file mode 100644
index 0000000000..f8422e2a8f
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.extclients.aai;
+
+
+import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.EsrThirdpartySdncList;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AaiServiceProviderImpl implements AaiServiceProvider {
+
+ private static final Logger logger = LoggerFactory.getLogger(AaiServiceProviderImpl.class);
+
+ private final AaiClientProvider aaiClientProvider;
+
+ @Autowired
+ public AaiServiceProviderImpl(final AaiClientProvider aaiClientProvider) {
+ this.aaiClientProvider = aaiClientProvider;
+ }
+
+ @Override
+ public EsrThirdpartySdncList invokeGetThirdPartySdncList() {
+ return aaiClientProvider.getAaiClient()
+ .get(EsrThirdpartySdncList.class, AAIUriFactory.createResourceUri(AAIObjectType.THIRDPARTY_SDNC_LIST))
+ .orElseGet(() -> {
+ logger.debug("No VNFMs in AAI");
+ return null;
+ });
+ }
+
+ @Override
+ public EsrSystemInfoList invokeGetThirdPartySdncEsrSystemInfo(String sdncId) {
+ return aaiClientProvider.getAaiClient()
+ .get(EsrSystemInfoList.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.THIRDPARTY_SDNC_SYSTEM_INFO_LIST, sdncId))
+ .orElseGet(() -> {
+ logger.debug("VNFM not found in AAI");
+ return null;
+ });
+ }
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java
new file mode 100644
index 0000000000..188349c0bf
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.model;
+
+public class ErrorResponse {
+
+ private int status;
+
+ private String error;
+
+ private String message;
+
+ public ErrorResponse(int status, String message) {
+ this.status = status;
+ this.message = message;
+ this.error = "Bad Request";
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getError() {
+ if (status == 500) {
+ this.error = "Internal Server Error";
+ }
+ return error;
+ }
+
+ public void setError(String error) {
+ this.error = error;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenRequest.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenRequest.java
new file mode 100644
index 0000000000..3590c683e6
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenRequest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.model;
+
+public class TokenRequest {
+
+ private String grantType;
+
+ private String userName;
+
+ private String value;
+
+ public String getGrantType() {
+ return grantType;
+ }
+
+ public void setGrantType(String grantType) {
+ this.grantType = grantType;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java
new file mode 100644
index 0000000000..8007075e04
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.model;
+
+public class TokenResponse {
+
+ private String accessToken;
+
+ private int expires;
+
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+ public int getExpires() {
+ return expires;
+ }
+
+ public void setExpires(int expires) {
+ this.expires = expires;
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java
new file mode 100644
index 0000000000..f6abd98794
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.rest;
+
+public enum HttpMethod {
+ GET, POST, PUT, DELETE, PATCH;
+
+ public static HttpMethod fromString(String s) {
+ if (s == null)
+ return null;
+ if (("get").equalsIgnoreCase(s))
+ return GET;
+ if (("post").equalsIgnoreCase(s))
+ return POST;
+ if (("put").equalsIgnoreCase(s))
+ return PUT;
+ if (("delete").equalsIgnoreCase(s))
+ return DELETE;
+ if (("patch").equalsIgnoreCase(s))
+ return PATCH;
+ throw new IllegalArgumentException("Invalid value for HTTP Method: " + s);
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java
new file mode 100644
index 0000000000..f2e651fd6e
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.rest;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+
+
+public enum JobStatus {
+ STARTED, PROCESSING, FINISHED, ERROR;
+
+ public static JobStatus fromString(String s) throws ApplicationException {
+ if (s == null)
+ return null;
+ if (("started").equalsIgnoreCase(s))
+ return STARTED;
+ if (("processing").equalsIgnoreCase(s))
+ return PROCESSING;
+ if (("finished").equalsIgnoreCase(s))
+ return FINISHED;
+ if (("error").equalsIgnoreCase(s))
+ return ERROR;
+ throw new ApplicationException(500, "Invalid value for Job " + "Status: " + s);
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java
new file mode 100644
index 0000000000..d8e1e36058
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java
@@ -0,0 +1,205 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.rest;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.beans.nsmf.JobStatusRequest;
+import org.onap.so.beans.nsmf.NssiActDeActRequest;
+import org.onap.so.beans.nsmf.NssiAllocateRequest;
+import org.onap.so.beans.nsmf.NssiCreateRequest;
+import org.onap.so.beans.nsmf.NssiDeAllocateRequest;
+import org.onap.so.beans.nsmf.NssiTerminateRequest;
+import org.onap.so.beans.nsmf.NssiUpdateRequest;
+import org.onap.so.beans.nsmf.NssiUpdateRequestById;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.assertObjectNotNull;
+
+@Controller
+@RequestMapping(value = "/api/rest/provMns/v1", produces = {APPLICATION_JSON}, consumes = {APPLICATION_JSON})
+public class NssmfAdapterRest {
+
+ private static final Logger logger = LoggerFactory.getLogger(NssmfAdapterRest.class);
+
+ @Autowired
+ private NssmfManager nssmfMgr;
+
+ @PostMapping(value = "/NSS/SliceProfiles")
+ public ResponseEntity allocateNssi(@RequestBody NssiAllocateRequest allocate) {
+ try {
+ logger.info("Nssmi allocate request is invoked");
+ assertObjectNotNull(allocate);
+ RestResponse rsp = getNssmfMgr().allocateNssi(allocate);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @PostMapping(value = "/NSS/nssi")
+ public ResponseEntity createNssi(@RequestBody NssiCreateRequest create) {
+ try {
+ logger.info("Nssmf create request is invoked");
+ assertObjectNotNull(create);
+ RestResponse rsp = getNssmfMgr().createNssi(create);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @PostMapping(value = "/NSS/SliceProfiles/{sliceProfileId}")
+ public ResponseEntity deAllocateNssi(@RequestBody NssiDeAllocateRequest deAllocate,
+ @PathVariable("sliceProfileId") final String sliceId) {
+ try {
+ logger.info("Nssmf deallocate request is invoked");
+ assertObjectNotNull(deAllocate);
+ RestResponse rsp = getNssmfMgr().deAllocateNssi(deAllocate, sliceId);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @PostMapping(value = "/NSS/nssi/{nssiId}")
+ public ResponseEntity terminateNssi(@RequestBody NssiTerminateRequest terminate,
+ @PathVariable("nssiId") String nssiId) {
+ try {
+ logger.info("Nssmf terminate request is invoked");
+ assertObjectNotNull(terminate);
+ RestResponse rsp = getNssmfMgr().terminateNssi(terminate, nssiId);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @PutMapping(value = "/NSS/SliceProfiles/{sliceProfileId}")
+ public ResponseEntity modifyNssi(@RequestBody NssiUpdateRequest update,
+ @PathVariable("sliceProfileId") String sliceId) {
+ try {
+ logger.info("Nssmf modify request is invoked");
+ assertObjectNotNull(update);
+ RestResponse rsp = getNssmfMgr().updateNssi(update, sliceId);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @PutMapping(value = "/NSS/nssi/{nssiId}")
+ public ResponseEntity modifyNssiById(@RequestBody NssiUpdateRequestById updateById,
+ @PathVariable("nssiId") String nssiId) {
+ try {
+ logger.info("Nssmf modify by ID request is invoked");
+ assertObjectNotNull(updateById);
+ RestResponse rsp = getNssmfMgr().updateNssiById(updateById, nssiId);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @PostMapping(value = "/NSS/{snssai}/activation")
+ public ResponseEntity activateNssi(@RequestBody NssiActDeActRequest activate,
+ @PathVariable("snssai") String snssai) {
+ try {
+ logger.info("Nssmf activate request is invoked");
+ assertObjectNotNull(activate);
+ RestResponse rsp = getNssmfMgr().activateNssi(activate, snssai);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @PostMapping(value = "/NSS/{snssai}/deactivation")
+ public ResponseEntity deactivateNssi(@RequestBody NssiActDeActRequest deActivate,
+ @PathVariable("snssai") String snssai) {
+ try {
+ logger.info("Nssmf activate request is invoked");
+ assertObjectNotNull(deActivate);
+ RestResponse rsp = getNssmfMgr().deActivateNssi(deActivate, snssai);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @PostMapping(value = "/NSS/jobs/{jobId}")
+ public ResponseEntity queryJobStatus(@RequestBody JobStatusRequest jobStatusReq,
+ @PathVariable("jobId") String jobId) {
+ try {
+ logger.info("Nssmf query job status request is invoked");
+ assertObjectNotNull(jobStatusReq);
+ RestResponse rsp = getNssmfMgr().queryJobStatus(jobStatusReq, jobId);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @GetMapping(value = "/vendor/{vendorName}/type/{networkType}/NSS" + "/SliceProfiles/{sliceProfileId}")
+ public ResponseEntity queryNssi(@PathVariable("vendorName") String vendorName,
+ @PathVariable("networktype") String networkType, @PathVariable("sliceProfileId") String sliceId) {
+ try {
+ logger.info("Nssmf query nssi request is invoked");
+ RestResponse rsp = getNssmfMgr().queryNssi(vendorName, networkType, sliceId);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @GetMapping(value = "/vendor/{vendorName}/type/{networkType}/NSS/nssi" + "/{nssiId}")
+ public ResponseEntity queryNssiById(@PathVariable("vendorName") String vendorName,
+ @PathVariable("networkTtype") String networkType, @PathVariable("nssiId") String nssiId) {
+ try {
+ logger.info("Nssmf query nssi by ID request is invoked");
+ RestResponse rsp = getNssmfMgr().queryNssiById(vendorName, networkType, nssiId);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ public void setNssmfMgr(NssmfManager nssmfMgr) {
+ this.nssmfMgr = nssmfMgr;
+ }
+
+ public NssmfManager getNssmfMgr() {
+ return nssmfMgr;
+ }
+
+ private ResponseEntity buildResponse(RestResponse rsp) {
+ return ResponseEntity.status(rsp.getStatus()).body(rsp.getResponseContent());
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java
new file mode 100644
index 0000000000..6306643a97
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.rest;
+
+public class NssmfInfo {
+
+ private String url;
+
+ private String ipAddress;
+
+ private String port;
+
+ private String insecure;
+
+ private String cacert;
+
+ private String userName;
+
+ private String password;
+
+ public String getInsecure() {
+ return insecure;
+ }
+
+ public void setInsecure(String insecure) {
+ this.insecure = insecure;
+ }
+
+ public String getCacert() {
+ return cacert;
+ }
+
+ public void setCacert(String cacert) {
+ this.cacert = cacert;
+ }
+
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java
new file mode 100644
index 0000000000..0e25729610
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java
@@ -0,0 +1,541 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.rest;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.beans.nsmf.ActDeActNssi;
+import org.onap.so.beans.nsmf.AllocateAnNssi;
+import org.onap.so.beans.nsmf.AllocateCnNssi;
+import org.onap.so.beans.nsmf.AllocateTnNssi;
+import org.onap.so.beans.nsmf.CreateCnNssi;
+import org.onap.so.beans.nsmf.DeAllocateNssi;
+import org.onap.so.beans.nsmf.EsrInfo;
+import org.onap.so.beans.nsmf.JobStatusRequest;
+import org.onap.so.beans.nsmf.JobStatusResponse;
+import org.onap.so.beans.nsmf.NetworkType;
+import org.onap.so.beans.nsmf.NssiActDeActRequest;
+import org.onap.so.beans.nsmf.NssiAllocateRequest;
+import org.onap.so.beans.nsmf.NssiCreateRequest;
+import org.onap.so.beans.nsmf.NssiDeAllocateRequest;
+import org.onap.so.beans.nsmf.NssiResponse;
+import org.onap.so.beans.nsmf.NssiTerminateRequest;
+import org.onap.so.beans.nsmf.NssiUpdateRequest;
+import org.onap.so.beans.nsmf.NssiUpdateRequestById;
+import org.onap.so.beans.nsmf.ResponseDescriptor;
+import org.onap.so.beans.nsmf.TerminateNssi;
+import org.onap.so.beans.nsmf.UpdateCnNssi;
+import org.onap.so.beans.nsmf.UpdateCnNssiById;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.domain.Example;
+import org.springframework.stereotype.Component;
+import static java.lang.String.valueOf;
+import static org.onap.so.adapters.nssmf.rest.HttpMethod.DELETE;
+import static org.onap.so.adapters.nssmf.rest.HttpMethod.GET;
+import static org.onap.so.adapters.nssmf.rest.HttpMethod.POST;
+import static org.onap.so.adapters.nssmf.rest.HttpMethod.PUT;
+import static org.onap.so.adapters.nssmf.rest.JobStatus.ERROR;
+import static org.onap.so.adapters.nssmf.rest.JobStatus.FINISHED;
+import static org.onap.so.adapters.nssmf.rest.JobStatus.PROCESSING;
+import static org.onap.so.adapters.nssmf.rest.JobStatus.STARTED;
+import static org.onap.so.adapters.nssmf.rest.JobStatus.fromString;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.ACTIVATE_NSS_SUCCESS;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.ALLOCATE_NSS_SUCCESS;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.CREATE_NSS_SUCCESS;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.DEACTIVATE_NSS_SUCCESS;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.DEALLOCATE_NSS_SUCCESS;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_FAILED;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_SUCCESS;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.assertObjectNotNull;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
+import static org.onap.so.beans.nsmf.ActDeActNssi.ACT_URL;
+import static org.onap.so.beans.nsmf.ActDeActNssi.DE_ACT_URL;
+
+@Component
+@Primary
+public class NssmfManager {
+
+ private static final Logger logger = LoggerFactory.getLogger(NssmfManager.class);
+
+ public final static String QUERY = "/api/rest/provMns/v1/NSS" + "/SliceProfiles/{sliceProfileId}";
+
+ public final static String QUERY_BY_ID = "/api/rest/provMns/v1/NSS/nssi" + "/{nssiId}";
+
+ @Autowired
+ private ResourceOperationStatusRepository rscOperStatusRepo;
+
+ @Autowired
+ private RestUtil restUtil;
+
+
+ public RestResponse allocateNssi(NssiAllocateRequest nssmiAllocate) throws ApplicationException {
+
+ assertObjectNotNull(nssmiAllocate.getEsrInfo());
+ assertObjectNotNull(nssmiAllocate.getEsrInfo().getNetworkType());
+ assertObjectNotNull(nssmiAllocate.getEsrInfo().getVendor());
+
+ String nsiId = null;
+ String allocateReq = null;
+ String allocateUrl = null;
+ logger.info("Allocate Nssi for " + nssmiAllocate.getEsrInfo().getNetworkType() + " Network has begun");
+
+ switch (nssmiAllocate.getEsrInfo().getNetworkType()) {
+
+ case CORE:
+ AllocateCnNssi cn = nssmiAllocate.getAllocateCnNssi();
+ assertObjectNotNull(cn);
+ assertObjectNotNull(cn.getNsiInfo());
+ assertObjectNotNull(cn.getNsiInfo().getNsiId());
+ nsiId = cn.getNsiInfo().getNsiId();
+ assertObjectNotNull(nsiId);
+ allocateReq = marshal(cn);
+ allocateUrl = AllocateCnNssi.URL;
+ break;
+
+ case ACCESS:
+ AllocateAnNssi an = nssmiAllocate.getAllocateAnNssi();
+ assertObjectNotNull(an);
+ assertObjectNotNull(an.getNsiInfo());
+ assertObjectNotNull(an.getNsiInfo().getNsiId());
+ nsiId = an.getNsiInfo().getNsiId();
+ assertObjectNotNull(nsiId);
+ allocateReq = marshal(an);
+ allocateUrl = AllocateAnNssi.URL;
+ break;
+
+ case TRANSPORT:
+ AllocateTnNssi tn = nssmiAllocate.getAllocateTnNssi();
+ assertObjectNotNull(tn);
+ assertObjectNotNull(tn.getNsiInfo());
+ assertObjectNotNull(tn.getNsiInfo().getNsiId());
+ nsiId = tn.getNsiInfo().getNsiId();
+ allocateReq = marshal(tn);
+ allocateUrl = AllocateTnNssi.URL;
+ break;
+
+ }
+ RestResponse rsp = restUtil.sendRequest(allocateUrl, POST, allocateReq, nssmiAllocate.getEsrInfo());
+ assertObjectNotNull(rsp);
+
+ if (valueOf(rsp.getStatus()).startsWith("2")) {
+ NssiResponse allocateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class);
+
+ ResourceOperationStatus status =
+ new ResourceOperationStatus(allocateRes.getNssiId(), allocateRes.getJobId(), nsiId);
+ logger.info("save segment and operaton info -> begin");
+ updateDbStatus(status, rsp.getStatus(), STARTED, ALLOCATE_NSS_SUCCESS);
+ logger.info("save segment and operation info -> end");
+ }
+ return rsp;
+ }
+
+ public RestResponse createNssi(NssiCreateRequest nssiCreate) throws ApplicationException {
+
+ assertObjectNotNull(nssiCreate.getEsrInfo());
+ assertObjectNotNull(nssiCreate.getEsrInfo().getNetworkType());
+ assertObjectNotNull(nssiCreate.getEsrInfo().getVendor());
+
+ String nsiId = null;
+ String createReq = null;
+ String createUrl = null;
+ logger.info("Create Nssi for " + nssiCreate.getEsrInfo().getNetworkType() + " Network has begun");
+
+ switch (nssiCreate.getEsrInfo().getNetworkType()) {
+ case CORE:
+ CreateCnNssi cn = nssiCreate.getCreateCnNssi();
+ nsiId = cn.getNsiInfo().getNsiId();
+ assertObjectNotNull(nsiId);
+ createReq = marshal(cn);
+ createUrl = AllocateCnNssi.URL;
+ break;
+
+ case ACCESS:
+ case TRANSPORT:
+ throw new ApplicationException(1, "Create Nssi doesn't " + "support the Network type:"
+ + nssiCreate.getEsrInfo().getNetworkType());
+ }
+ RestResponse rsp = restUtil.sendRequest(createUrl, POST, createReq, nssiCreate.getEsrInfo());
+ assertObjectNotNull(rsp);
+
+ if (valueOf(rsp.getStatus()).startsWith("2")) {
+ NssiResponse allocateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class);
+
+ ResourceOperationStatus status =
+ new ResourceOperationStatus(allocateRes.getNssiId(), allocateRes.getJobId(), nsiId);
+ logger.info("save segment and operaton info -> begin");
+ updateDbStatus(status, rsp.getStatus(), STARTED, CREATE_NSS_SUCCESS);
+ logger.info("save segment and operaton info -> end");
+ }
+ return rsp;
+ }
+
+ public RestResponse deAllocateNssi(NssiDeAllocateRequest nssiDeallocate, String sliceId)
+ throws ApplicationException {
+
+ assertObjectNotNull(nssiDeallocate.getEsrInfo());
+ assertObjectNotNull(nssiDeallocate.getEsrInfo().getNetworkType());
+ assertObjectNotNull(nssiDeallocate.getEsrInfo().getVendor());
+
+ DeAllocateNssi deAllocate = nssiDeallocate.getDeAllocateNssi();
+
+ assertObjectNotNull(sliceId);
+ assertObjectNotNull(deAllocate.getNssiId());
+ assertObjectNotNull(deAllocate.getNsiId());
+
+ String deallocateUrl = formTnAndAnUrl(nssiDeallocate.getEsrInfo(), DeAllocateNssi.URL, sliceId);
+ String deAllocateReq = marshal(deAllocate);
+
+ logger.info("Deallocate Nssi has begun");
+
+ RestResponse rsp = restUtil.sendRequest(deallocateUrl, DELETE, deAllocateReq, nssiDeallocate.getEsrInfo());
+ assertObjectNotNull(rsp);
+
+ if (valueOf(rsp.getStatus()).startsWith("2")) {
+ NssiResponse res = unMarshal(rsp.getResponseContent(), NssiResponse.class);
+
+ ResourceOperationStatus status =
+ new ResourceOperationStatus(deAllocate.getNssiId(), res.getJobId(), deAllocate.getNsiId());
+ logger.info("save segment and operaton info -> begin");
+ updateDbStatus(status, rsp.getStatus(), STARTED, DEALLOCATE_NSS_SUCCESS);
+ logger.info("save segment and operaton info -> end");
+ }
+ return rsp;
+ }
+
+ private String formTnAndAnUrl(EsrInfo esrInfo, String origUrl, String variable) {
+
+ origUrl = formatUrl(origUrl, variable);
+ String[] val;
+
+ switch (esrInfo.getNetworkType()) {
+
+ case TRANSPORT:
+ val = origUrl.split("v1");
+ return val[0] + "v1/tn" + val[1];
+
+ case ACCESS:
+ val = origUrl.split("v1");
+ return val[0] + "v1/an" + val[1];
+
+ case CORE:
+ return origUrl;
+ }
+ return origUrl;
+ }
+
+ private String formatUrl(String origUrl, String variable) {
+
+ if (variable != null) {
+ origUrl = String.format(origUrl, variable);
+ }
+ return origUrl;
+ }
+
+
+ public RestResponse terminateNssi(NssiTerminateRequest nssiTerminate, String nssiId) throws ApplicationException {
+
+ assertObjectNotNull(nssiTerminate.getEsrInfo());
+ assertObjectNotNull(nssiTerminate.getEsrInfo().getNetworkType());
+ assertObjectNotNull(nssiTerminate.getEsrInfo().getVendor());
+
+ TerminateNssi terminate = nssiTerminate.getTerminateNssi();
+
+ assertObjectNotNull(nssiId);
+ assertObjectNotNull(terminate.getNsiId());
+
+ logger.info("Terminate Nssi has begun");
+
+ String terminateUrl = formTnAndAnUrl(nssiTerminate.getEsrInfo(), TerminateNssi.URL, nssiId);
+ String terminateReq = marshal(terminate);
+
+ RestResponse rsp = restUtil.sendRequest(terminateUrl, DELETE, terminateReq, nssiTerminate.getEsrInfo());
+ assertObjectNotNull(rsp);
+
+ if (valueOf(rsp.getStatus()).startsWith("2")) {
+ NssiResponse res = unMarshal(rsp.getResponseContent(), NssiResponse.class);
+
+ ResourceOperationStatus status = new ResourceOperationStatus(nssiId, res.getJobId(), terminate.getNsiId());
+ logger.info("save segment and operaton info -> begin");
+ updateDbStatus(status, rsp.getStatus(), STARTED, DEALLOCATE_NSS_SUCCESS);
+ logger.info("save segment and operaton info -> end");
+ }
+ return rsp;
+ }
+
+ public RestResponse activateNssi(NssiActDeActRequest nssiActivate, String snssai) throws ApplicationException {
+
+ assertObjectNotNull(nssiActivate.getEsrInfo());
+ assertObjectNotNull(nssiActivate.getEsrInfo().getNetworkType());
+ assertObjectNotNull(nssiActivate.getEsrInfo().getVendor());
+
+ ActDeActNssi activate = nssiActivate.getActDeActNssi();
+
+ assertObjectNotNull(snssai);
+ assertObjectNotNull(activate.getNssiId());
+ assertObjectNotNull(activate.getNsiId());
+
+ logger.info("Activate Nssi has begun");
+
+ String activateUrl = formTnAndAnUrl(nssiActivate.getEsrInfo(), ACT_URL, snssai);
+ String activateReq = marshal(activate);
+
+ RestResponse rsp = restUtil.sendRequest(activateUrl, PUT, activateReq, nssiActivate.getEsrInfo());
+ assertObjectNotNull(rsp);
+
+ if (valueOf(rsp.getStatus()).startsWith("2")) {
+ NssiResponse activateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class);
+
+ ResourceOperationStatus status =
+ new ResourceOperationStatus(activate.getNssiId(), activateRes.getJobId(), activate.getNsiId());
+ logger.info("save segment and operaton info -> begin");
+ updateDbStatus(status, rsp.getStatus(), STARTED, ACTIVATE_NSS_SUCCESS);
+ logger.info("save segment and operaton info -> end");
+ }
+ return rsp;
+ }
+
+ public RestResponse deActivateNssi(NssiActDeActRequest nssiDeActivate, String snssai) throws ApplicationException {
+
+ assertObjectNotNull(nssiDeActivate.getEsrInfo());
+ assertObjectNotNull(nssiDeActivate.getEsrInfo().getNetworkType());
+ assertObjectNotNull(nssiDeActivate.getEsrInfo().getVendor());
+
+ logger.info("Deactivate Nssi has begun");
+
+ ActDeActNssi deActivate = nssiDeActivate.getActDeActNssi();
+
+ assertObjectNotNull(snssai);
+ assertObjectNotNull(deActivate.getNssiId());
+ assertObjectNotNull(deActivate.getNsiId());
+
+ String deActivateUrl = formTnAndAnUrl(nssiDeActivate.getEsrInfo(), DE_ACT_URL, snssai);
+ String deActivateReq = marshal(deActivate);
+
+ RestResponse rsp = restUtil.sendRequest(deActivateUrl, PUT, deActivateReq, nssiDeActivate.getEsrInfo());
+ assertObjectNotNull(rsp);
+
+ if (valueOf(rsp.getStatus()).startsWith("2")) {
+ NssiResponse deActivateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class);
+
+ ResourceOperationStatus status = new ResourceOperationStatus(deActivate.getNssiId(),
+ deActivateRes.getJobId(), deActivate.getNsiId());
+ logger.info("save segment and operaton info -> begin");
+ updateDbStatus(status, rsp.getStatus(), STARTED, DEACTIVATE_NSS_SUCCESS);
+ logger.info("save segment and operaton info -> end");
+ }
+ return rsp;
+ }
+
+ public RestResponse queryJobStatus(JobStatusRequest jobReq, String jobId) throws ApplicationException {
+
+ assertObjectNotNull(jobReq.getEsrInfo());
+ assertObjectNotNull(jobReq.getEsrInfo().getNetworkType());
+ assertObjectNotNull(jobReq.getEsrInfo().getVendor());
+ assertObjectNotNull(jobId);
+ assertObjectNotNull(jobReq.getNssiId());
+ assertObjectNotNull(jobReq.getNsiId());
+
+ logger.info("Query job status has begun");
+
+ ResourceOperationStatus status = new ResourceOperationStatus(jobReq.getNssiId(), jobId, jobReq.getNsiId());
+ status = rscOperStatusRepo.findOne(Example.of(status))
+ .orElseThrow(() -> new ApplicationException(404, "Cannot Find Operation Status"));
+
+ String statusUrl = formatUrl(JobStatusRequest.URL, jobId);
+ if (jobReq.getResponseId() != null) {
+ statusUrl = statusUrl + "?responseId=" + jobReq.getResponseId();
+ }
+
+ RestResponse rsp = restUtil.sendRequest(statusUrl, GET, "", jobReq.getEsrInfo());
+ assertObjectNotNull(rsp);
+
+ if (!valueOf(rsp.getStatus()).startsWith("2")) {
+ updateDbStatus(status, rsp.getStatus(), ERROR, QUERY_JOB_STATUS_FAILED);
+ throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED);
+ }
+
+ ResponseDescriptor rspDesc =
+ unMarshal(rsp.getResponseContent(), JobStatusResponse.class).getResponseDescriptor();
+ logger.info("save segment and operaton info -> begin");
+ updateRequestDbJobStatus(rspDesc, status, rsp);
+ logger.info("save segment and operaton info -> end");
+ return rsp;
+ }
+
+
+ public RestResponse updateNssi(NssiUpdateRequest nssiUpdate, String sliceId) throws ApplicationException {
+
+ assertObjectNotNull(nssiUpdate.getEsrInfo());
+ assertObjectNotNull(nssiUpdate.getEsrInfo().getNetworkType());
+ assertObjectNotNull(nssiUpdate.getEsrInfo().getVendor());
+ assertObjectNotNull(sliceId);
+
+ String nsiId = null;
+ String nssiId = null;
+ String updateReq = null;
+ String updateUrl = null;
+ logger.info("Update Nssi for " + nssiUpdate.getEsrInfo().getNetworkType() + " Network has begun");
+
+ switch (nssiUpdate.getEsrInfo().getNetworkType()) {
+ case CORE:
+ UpdateCnNssi cn = nssiUpdate.getUpdateCnNssi();
+ nsiId = cn.getNsiInfo().getNsiId();
+ nssiId = cn.getNssiId();
+ assertObjectNotNull(nsiId);
+ assertObjectNotNull(nssiId);
+ updateReq = marshal(cn);
+ updateUrl = formatUrl(UpdateCnNssi.URL, sliceId);
+ break;
+
+ case ACCESS:
+ case TRANSPORT:
+ throw new ApplicationException(1, "Update Nssi doesn't " + "support the Network type:"
+ + nssiUpdate.getEsrInfo().getNetworkType());
+ }
+
+ RestResponse rsp = restUtil.sendRequest(updateUrl, PUT, updateReq, nssiUpdate.getEsrInfo());
+ assertObjectNotNull(rsp);
+
+ if (valueOf(rsp.getStatus()).startsWith("2")) {
+ NssiResponse allocateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class);
+
+ ResourceOperationStatus status = new ResourceOperationStatus(nssiId, allocateRes.getJobId(), nsiId);
+ logger.info("save segment and operaton info -> begin");
+ updateDbStatus(status, rsp.getStatus(), STARTED, ALLOCATE_NSS_SUCCESS);
+ logger.info("save segment and operaton info -> end");
+ }
+ return rsp;
+ }
+
+ public RestResponse updateNssiById(NssiUpdateRequestById nssiUpdateById, String nssiId)
+ throws ApplicationException {
+
+ assertObjectNotNull(nssiUpdateById.getEsrInfo());
+ assertObjectNotNull(nssiUpdateById.getEsrInfo().getNetworkType());
+ assertObjectNotNull(nssiUpdateById.getEsrInfo().getVendor());
+ assertObjectNotNull(nssiId);
+
+ String nsiId = null;
+ String updateReq = null;
+ String updateUrl = null;
+ logger.info("Update Nssi by ID for " + nssiUpdateById.getEsrInfo().getNetworkType() + " Network has begun");
+
+ switch (nssiUpdateById.getEsrInfo().getNetworkType()) {
+ case CORE:
+ UpdateCnNssiById cn = nssiUpdateById.getUpdateCnNssiById();
+ nsiId = cn.getNsiInfo().getNsiId();
+ assertObjectNotNull(nsiId);
+ updateReq = marshal(cn);
+ updateUrl = formatUrl(UpdateCnNssiById.URL, nssiId);
+ break;
+
+ case ACCESS:
+ case TRANSPORT:
+ throw new ApplicationException(1, "Update Nssi doesn't " + "support the Network type:"
+ + nssiUpdateById.getEsrInfo().getNetworkType());
+ }
+
+ RestResponse rsp = restUtil.sendRequest(updateUrl, PUT, updateReq, nssiUpdateById.getEsrInfo());
+ assertObjectNotNull(rsp);
+
+ if (valueOf(rsp.getStatus()).startsWith("2")) {
+ NssiResponse allocateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class);
+
+ ResourceOperationStatus status = new ResourceOperationStatus(nssiId, allocateRes.getJobId(), nsiId);
+ logger.info("save segment and operaton info -> begin");
+ updateDbStatus(status, rsp.getStatus(), STARTED, ALLOCATE_NSS_SUCCESS);
+ logger.info("save segment and operaton info -> end");
+ }
+ return rsp;
+ }
+
+ public RestResponse queryNssi(String vendor, String type, String sliceId) throws ApplicationException {
+
+ logger.info("Query Nssi has begun");
+ String getUrl = formatUrl(QUERY, sliceId);
+ EsrInfo esr = new EsrInfo();
+ esr.setVendor(vendor);
+ esr.setNetworkType(NetworkType.valueOf(type));
+ RestResponse rsp = restUtil.sendRequest(getUrl, GET, "", esr);
+ assertObjectNotNull(rsp);
+ return rsp;
+ }
+
+ public RestResponse queryNssiById(String vendor, String type, String nssiId) throws ApplicationException {
+
+ logger.info("Query Nssi by ID has begun");
+ String getUrl = formatUrl(QUERY_BY_ID, nssiId);
+ EsrInfo esr = new EsrInfo();
+ esr.setVendor(vendor);
+ esr.setNetworkType(NetworkType.valueOf(type));
+ RestResponse rsp = restUtil.sendRequest(getUrl, GET, "", esr);
+ assertObjectNotNull(rsp);
+ return rsp;
+ }
+
+ private void updateRequestDbJobStatus(ResponseDescriptor rspDesc, ResourceOperationStatus status, RestResponse rsp)
+ throws ApplicationException {
+
+ switch (fromString(rspDesc.getStatus())) {
+
+ case STARTED:
+ updateDbStatus(status, rsp.getStatus(), STARTED, QUERY_JOB_STATUS_SUCCESS);
+ break;
+
+ case ERROR:
+ updateDbStatus(status, rsp.getStatus(), ERROR, QUERY_JOB_STATUS_FAILED);
+ throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED);
+
+ case FINISHED:
+ if (rspDesc.getProgress() == 100) {
+ updateDbStatus(status, rsp.getStatus(), FINISHED, QUERY_JOB_STATUS_SUCCESS);
+ }
+ break;
+
+ case PROCESSING:
+ updateDbStatus(status, rsp.getStatus(), PROCESSING, QUERY_JOB_STATUS_SUCCESS);
+ break;
+ }
+ }
+
+ private void updateDbStatus(ResourceOperationStatus status, int rspStatus, JobStatus jobStatus,
+ String description) {
+ status.setErrorCode(valueOf(rspStatus));
+ status.setStatus(jobStatus.toString());
+ status.setStatusDescription(description);
+ logger.info("Updating DB status");
+ rscOperStatusRepo.save(status);
+ logger.info("Updating successful");
+ }
+
+ public void setRscOperStatusRepo(ResourceOperationStatusRepository rscOperStatusRepo) {
+ this.rscOperStatusRepo = rscOperStatusRepo;
+ }
+
+ public void setRestUtil(RestUtil restUtil) {
+ this.restUtil = restUtil;
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java
new file mode 100644
index 0000000000..cc047e45c7
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.rest;
+
+import java.util.Map;
+
+public class RestResponse {
+
+ // the response content
+ private String responseContent;
+
+ // the response status
+ private int status;
+
+ // the response header
+ private Map<String, String> respHeaderMap;
+
+ public RestResponse() {
+ this.status = -1;
+
+ this.respHeaderMap = null;
+ }
+
+ public int getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public Map<String, String> getRespHeaderMap() {
+ return this.respHeaderMap;
+ }
+
+ public void setRespHeaderMap(Map<String, String> header) {
+ this.respHeaderMap = header;
+ }
+
+ public int getRespHeaderInt(String key) {
+ if (this.respHeaderMap != null) {
+ String result = this.respHeaderMap.get(key);
+ if (result != null) {
+ return Integer.parseInt(result);
+ }
+ }
+ return -1;
+ }
+
+ public long getRespHeaderLong(String key) {
+ if (this.respHeaderMap != null) {
+ String result = this.respHeaderMap.get(key);
+ if (result != null) {
+ return Long.parseLong(result);
+ }
+ }
+ return -1L;
+ }
+
+ public String getRespHeaderStr(String key) {
+ if (this.respHeaderMap != null) {
+ return this.respHeaderMap.get(key);
+ }
+ return null;
+ }
+
+ public String getResponseContent() {
+ return this.responseContent;
+ }
+
+ public void setResponseContent(String responseString) {
+ this.responseContent = responseString;
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java
new file mode 100644
index 0000000000..3592d4f6a3
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java
@@ -0,0 +1,307 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.rest;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import javax.ws.rs.core.UriBuilder;
+import java.net.SocketTimeoutException;
+import java.net.URI;
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.util.EntityUtils;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.EsrThirdpartySdnc;
+import org.onap.aai.domain.yang.EsrThirdpartySdncList;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.extclients.aai.AaiServiceProvider;
+import org.onap.so.adapters.nssmf.model.TokenRequest;
+import org.onap.so.adapters.nssmf.model.TokenResponse;
+import org.onap.so.beans.nsmf.EsrInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import static org.apache.http.entity.ContentType.APPLICATION_JSON;
+import static org.onap.so.adapters.nssmf.rest.HttpMethod.POST;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.BAD_REQUEST;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
+import static org.onap.so.logger.ErrorCode.AvailabilityError;
+import static org.onap.so.logger.LoggingAnchor.FOUR;
+import static org.onap.so.logger.MessageEnum.RA_NS_EXC;
+
+@Component
+public class RestUtil {
+
+ private static final Logger logger = LoggerFactory.getLogger(RestUtil.class);
+
+ private static final int DEFAULT_TIME_OUT = 60000;
+
+ private static final String NSSMI_ADAPTER = "NSSMI Adapter";
+
+ private static final String TOKEN_URL = "/api/rest/securityManagement/v1" + "/oauth/token";
+
+ @Autowired
+ private AaiServiceProvider aaiSvcProv;
+
+
+ public NssmfInfo getNssmfHost(EsrInfo esrInfo) throws ApplicationException {
+ EsrThirdpartySdncList sdncList = aaiSvcProv.invokeGetThirdPartySdncList();
+ if (sdncList != null && sdncList.getEsrThirdpartySdnc() != null) {
+ for (EsrThirdpartySdnc sdncEsr : sdncList.getEsrThirdpartySdnc()) {
+
+ EsrSystemInfoList sysInfoList =
+ aaiSvcProv.invokeGetThirdPartySdncEsrSystemInfo(sdncEsr.getThirdpartySdncId());
+
+ if (sysInfoList != null && sysInfoList.getEsrSystemInfo() != null) {
+ for (EsrSystemInfo esr : sysInfoList.getEsrSystemInfo()) {
+ if (esr != null && esr.getType().equals(esrInfo.getNetworkType().getNetworkType())
+ && esr.getVendor().equals(esrInfo.getVendor())) {
+ logger.info("Found an entry with vendor name " + esrInfo.getVendor() + " and network type "
+ + esrInfo.getNetworkType() + " in ESR.");
+ NssmfInfo nssmfInfo = new NssmfInfo();
+ nssmfInfo.setIpAddress(esr.getIpAddress());
+ nssmfInfo.setPort(esr.getPort());
+ nssmfInfo.setCacert(esr.getSslCacert());
+ nssmfInfo.setUserName(esr.getUserName());
+ nssmfInfo.setPassword(esr.getPassword());
+ String endPoint = UriBuilder.fromPath("").host(esr.getIpAddress())
+ .port(Integer.valueOf(esr.getPort())).scheme("https").build().toString();
+ nssmfInfo.setUrl(endPoint);
+ return nssmfInfo;
+ }
+ }
+ }
+
+ }
+ }
+
+ throw new ApplicationException(BAD_REQUEST, "ESR information is improper");
+ }
+
+ public RestResponse sendRequest(String url, HttpMethod methodType, String content, EsrInfo esrInfo)
+ throws ApplicationException {
+
+ NssmfInfo nssmfInfo = getNssmfHost(esrInfo);
+
+ TokenRequest req = new TokenRequest();
+ req.setGrantType("password");
+ req.setUserName(nssmfInfo.getUserName());
+ req.setValue(nssmfInfo.getPassword());
+
+ String tokenReq = marshal(req);
+
+ logger.info("Sending token request to NSSMF: " + tokenReq);
+ RestResponse tokenRes = send(nssmfInfo.getUrl() + TOKEN_URL, POST, tokenReq, null);
+
+ TokenResponse res = unMarshal(tokenRes.getResponseContent(), TokenResponse.class);
+ String token = res.getAccessToken();
+ Header header = new BasicHeader("X-Auth-Token", token);
+ String nssmfUrl = nssmfInfo.getUrl() + url;
+ return send(nssmfUrl, methodType, content, header);
+ }
+
+ private RestResponse send(String url, HttpMethod methodType, String content, Header header) {
+
+ HttpRequestBase req = null;
+ HttpResponse res = null;
+
+ logger.debug("Beginning to send message {}: {}", methodType, url);
+
+ try {
+ int timeout = DEFAULT_TIME_OUT;
+
+ RequestConfig config = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout)
+ .setConnectionRequestTimeout(timeout).build();
+ logger.debug("Sending request to NSSMF: " + content);
+ req = getHttpReq(url, methodType, header, config, content);
+ res = getHttpsClient().execute(req);
+
+ String resContent = null;
+ if (res.getEntity() != null) {
+ resContent = EntityUtils.toString(res.getEntity(), "UTF-8");
+ }
+
+ int statusCode = res.getStatusLine().getStatusCode();
+ String statusMessage = res.getStatusLine().getReasonPhrase();
+ logger.info("NSSMF Response: {} {}", statusCode,
+ statusMessage + (resContent == null ? "" : System.lineSeparator() + resContent));
+
+ if (res.getStatusLine().getStatusCode() >= 300) {
+ String errMsg = "{\n \"errorCode\": " + res.getStatusLine().getStatusCode()
+ + "\n \"errorDescription\": " + statusMessage + "\n}";
+ logError(errMsg);
+ return createResponse(statusCode, errMsg);
+ }
+ if (null != req) {
+ req.reset();
+ } else {
+ logger.debug("method is NULL:");
+ }
+ req = null;
+
+ return createResponse(statusCode, resContent);
+
+ } catch (SocketTimeoutException | ConnectTimeoutException e) {
+ String errMsg = "Request to NSSMF timed out";
+ logError(errMsg, e);
+ return createResponse(408, errMsg);
+ } catch (Exception e) {
+ String errMsg = "Error processing request to NSSMF";
+ logError(errMsg, e);
+ return createResponse(500, errMsg);
+ } finally {
+ if (res != null) {
+ try {
+ EntityUtils.consume(res.getEntity());
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ }
+ }
+ if (req != null) {
+ try {
+ req.reset();
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ }
+ }
+ }
+ }
+
+ private RestResponse createResponse(int statusCode, String errMsg) {
+ RestResponse restResponse = new RestResponse();
+ restResponse.setStatus(statusCode);
+ restResponse.setResponseContent(errMsg);
+ return restResponse;
+ }
+
+ private HttpRequestBase getHttpReq(String url, HttpMethod method, Header header, RequestConfig config,
+ String content) throws ApplicationException {
+ HttpRequestBase base = null;
+ switch (method) {
+ case POST:
+ HttpPost post = new HttpPost(url);
+ post.setEntity(new StringEntity(content, APPLICATION_JSON));
+ base = post;
+ break;
+
+ case GET:
+ base = new HttpGet(url);
+ break;
+
+ case PUT:
+ HttpPut put = new HttpPut(url);
+ put.setEntity(new StringEntity(content, APPLICATION_JSON));
+ base = put;
+ break;
+
+ case PATCH:
+ break;
+
+ case DELETE:
+ HttpDeleteWithBody delete = new HttpDeleteWithBody(url);
+ if (content != null) {
+ delete.setEntity(new StringEntity(content, APPLICATION_JSON));
+ }
+ base = delete;
+ break;
+
+ }
+ base.setConfig(config);
+ if (header != null) {
+ base.setHeader(header);
+ }
+ return base;
+ }
+
+ class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
+ public static final String METHOD_NAME = "DELETE";
+
+ public String getMethod() {
+ return METHOD_NAME;
+ }
+
+ public HttpDeleteWithBody(final String uri) {
+ super();
+ setURI(URI.create(uri));
+ }
+
+ public HttpDeleteWithBody(final URI uri) {
+ super();
+ setURI(uri);
+ }
+
+ public HttpDeleteWithBody() {
+ super();
+ }
+ }
+
+
+ public HttpClient getHttpsClient() {
+
+ TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
+
+ public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
+ }};
+
+ // Install the all-trusting trust manager
+ try {
+ SSLContext sc = SSLContext.getInstance("SSL");
+ sc.init(null, trustAllCerts, new java.security.SecureRandom());
+ // HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+
+ SSLConnectionSocketFactory sslsf =
+ new SSLConnectionSocketFactory(sc, new String[] {"TLSv1"}, null, new TrustAllHostNameVerifier());
+ return HttpClients.custom().setSSLSocketFactory(sslsf).build();
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ private static void logError(String errMsg, Throwable t) {
+ logger.error(FOUR, RA_NS_EXC.toString(), NSSMI_ADAPTER, AvailabilityError.getValue(), errMsg, t);
+ }
+
+ private static void logError(String errMsg) {
+ logger.error(FOUR, RA_NS_EXC.toString(), NSSMI_ADAPTER, AvailabilityError.toString(), errMsg);
+ }
+}
+
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java
new file mode 100644
index 0000000000..254186bda8
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.rest;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSession;
+
+public class TrustAllHostNameVerifier implements HostnameVerifier {
+
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java
new file mode 100644
index 0000000000..b0b84d822b
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf.util;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.onap.so.logger.ErrorCode;
+import static org.onap.so.logger.LoggingAnchor.THREE;
+import static org.onap.so.logger.MessageEnum.RA_NS_EXC;
+
+public class NssmfAdapterUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NssmfAdapterUtil.class);
+
+ public static final int BAD_REQUEST = 400;
+
+ private static final String UNMARSHAL_FAIL_MSG = "Failed to unmarshal json";
+
+ private static final String MARSHAL_FAIL_MSG = "Failed to marshal object";
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ public static class StatusDesc {
+
+ public static final String ALLOCATE_NSS_SUCCESS = "Allocating nss is " + "successful";
+
+ public static final String CREATE_NSS_SUCCESS = "Creating nss is " + "successful";
+
+ public static final String DEALLOCATE_NSS_SUCCESS = "Deallocate nss " + "is successful";
+
+ public static final String ACTIVATE_NSS_SUCCESS = "Activate nss " + "is successful";
+
+ public static final String DEACTIVATE_NSS_SUCCESS = "Deactivate nss " + "is successful";
+
+ public static final String QUERY_JOB_STATUS_FAILED = "Query job " + "status failed";
+
+ public static final String QUERY_JOB_STATUS_SUCCESS = "Query job " + "status is successful";
+
+ private StatusDesc() {
+
+ }
+ }
+
+ private NssmfAdapterUtil() {
+
+ }
+
+ public static void assertObjectNotNull(Object object) throws ApplicationException {
+ if (null == object) {
+ LOGGER.error("Object is null.");
+ throw new ApplicationException(BAD_REQUEST, "An object is null.");
+ }
+ }
+
+ public static <T> T unMarshal(String jsonstr, Class<T> type) throws ApplicationException {
+ try {
+ return MAPPER.readValue(jsonstr, type);
+ } catch (IOException e) {
+ LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), UNMARSHAL_FAIL_MSG, e);
+ throw new ApplicationException(BAD_REQUEST, UNMARSHAL_FAIL_MSG);
+ }
+ }
+
+ public static String marshal(Object srcObj) throws ApplicationException {
+ try {
+ return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(srcObj);
+ } catch (IOException e) {
+ LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), MARSHAL_FAIL_MSG, e);
+ throw new ApplicationException(BAD_REQUEST, MARSHAL_FAIL_MSG);
+ }
+ }
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/adapters/mso-nssmf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties
new file mode 100644
index 0000000000..f93ec63f37
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties
@@ -0,0 +1 @@
+org.onap.so.adapters.nssmf.extclients.aai.AaiClientPropertiesImpl \ No newline at end of file
diff --git a/adapters/mso-nssmf-adapter/src/main/resources/application.yaml b/adapters/mso-nssmf-adapter/src/main/resources/application.yaml
new file mode 100644
index 0000000000..cb2f04d7ec
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/resources/application.yaml
@@ -0,0 +1,61 @@
+#
+# ============LICENSE_START=======================================================
+# ONAP - SO
+# ================================================================================
+# Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+# ================================================================================
+# 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=========================================================
+#/
+aai:
+ auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586
+ endpoint: https://aai.onap:30233
+logging:
+ path: logs
+
+spring:
+ datasource:
+ driver-class-name: org.mariadb.jdbc.Driver
+ jdbcUrl: jdbc:mariadb://192.168.235.44:30444/requestdb
+ username: root
+ password: secretpassword
+
+ jpa:
+ show-sql: false
+ hibernate:
+ dialect: org.hibernate.dialect.MySQL5Dialect
+ ddl-auto: validate
+ naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+ enable-lazy-load-no-trans: true
+server:
+ port: 8080
+ tomcat:
+ max-threads: 50
+
+mso:
+ key: 07a7159d3bf51a0e53be7a8f89699be7
+ site-name: localSite
+ logPath: ./logs/nssmf
+ msb-ip: msb-iag.{{ include "common.namespace" . }}
+ msb-port: 80
+ adapters:
+ requestDb:
+ endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083
+ auth: Basic YnBlbDpwYXNzd29yZDEk
+
+#Actuator
+management:
+ security:
+ enabled: false
+ basic:
+ enabled: false \ No newline at end of file
diff --git a/adapters/mso-nssmf-adapter/src/main/resources/nssmf.jks b/adapters/mso-nssmf-adapter/src/main/resources/nssmf.jks
new file mode 100644
index 0000000000..2ecce5bd3d
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/resources/nssmf.jks
Binary files differ
diff --git a/adapters/mso-nssmf-adapter/src/main/resources/nssmf.p12 b/adapters/mso-nssmf-adapter/src/main/resources/nssmf.p12
new file mode 100644
index 0000000000..25e7fbfca9
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/resources/nssmf.p12
Binary files differ
diff --git a/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.jks b/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.jks
new file mode 100644
index 0000000000..f7cd9e8f86
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.jks
Binary files differ
diff --git a/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.p12 b/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.p12
new file mode 100644
index 0000000000..1927b1f13f
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.p12
Binary files differ
diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java
new file mode 100644
index 0000000000..5bfd39096c
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java
@@ -0,0 +1,392 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.so.adapters.nssmf;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.LinkedList;
+import java.util.List;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.onap.so.adapters.nssmf.model.TokenResponse;
+import org.onap.so.adapters.nssmf.rest.HttpMethod;
+import org.onap.so.adapters.nssmf.rest.NssmfAdapterRest;
+import org.onap.so.adapters.nssmf.rest.NssmfInfo;
+import org.onap.so.adapters.nssmf.rest.NssmfManager;
+import org.onap.so.adapters.nssmf.rest.RestUtil;
+import org.onap.so.beans.nsmf.ActDeActNssi;
+import org.onap.so.beans.nsmf.AllocateCnNssi;
+import org.onap.so.beans.nsmf.CnSliceProfile;
+import org.onap.so.beans.nsmf.DeAllocateNssi;
+import org.onap.so.beans.nsmf.EsrInfo;
+import org.onap.so.beans.nsmf.JobStatusRequest;
+import org.onap.so.beans.nsmf.NsiInfo;
+import org.onap.so.beans.nsmf.NssiActDeActRequest;
+import org.onap.so.beans.nsmf.NssiAllocateRequest;
+import org.onap.so.beans.nsmf.NssiDeAllocateRequest;
+import org.onap.so.beans.nsmf.NssiResponse;
+import org.onap.so.beans.nsmf.PerfReq;
+import org.onap.so.beans.nsmf.PerfReqEmbbList;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
+import static org.onap.so.beans.nsmf.NetworkType.CORE;
+import static org.onap.so.beans.nsmf.ResourceSharingLevel.NON_SHARED;
+
+@RunWith(SpringRunner.class)
+public class NssmfAdapterRestTest {
+
+ private final static String ALLOCATE = "{\n" + " \"esrInfo\" : {\n" + " \"vendor\" : \"huawei\",\n"
+ + " \"networkType\" : \"cn\"\n" + " },\n" + " \"allocateCnNssi\" : {\n"
+ + " \"nssiId\" : \"NSST-C-001-HDBNJ-NSSMF-01-A-ZX\",\n" + " \"nssiName\" : \"eMBB-001\",\n"
+ + " \"sliceProfile\" : {\n" + " \"snssaiList\" : [ \"001-100001\" ],\n"
+ + " \"sliceProfileId\" : \"ab9af40f13f721b5f13539d87484098\",\n"
+ + " \"plmnIdList\" : [ \"460-00\", \"460-01\" ],\n" + " \"perfReq\" : {\n"
+ + " \"perfReqEmbbList\" : [ {\n" + " \"activityFactor\" : 50\n" + " } ]\n"
+ + " },\n" + " \"maxNumberofUEs\" : 200,\n"
+ + " \"coverageAreaTAList\" : [ \"1\", \"2\", \"3\" ],\n" + " \"latency\" : 6,\n"
+ + " \"resourceSharingLevel\" : \"non-shared\"\n" + " },\n" + " \"scriptName\" : \"CN1\",\n"
+ + " \"nsiInfo\" : {\n" + " \"nsiName\" : \"eMBB-001\",\n"
+ + " \"nsiId\" : \"NSI-M-001-HDBNJ-NSMF-01-A-ZX\"\n" + " }\n" + " }\n" + "}";
+
+ private NssmfManager nssmfMgr;
+
+ @Mock
+ private ResourceOperationStatusRepository rscOperStatusRepo;
+
+ @Mock
+ private RestUtil restUtil;
+
+ @Mock
+ private NssmfAdapterRest nssmfRest;
+
+ @Mock
+ private HttpResponse tokenResponse;
+
+ @Mock
+ private HttpEntity tokenEntity;
+
+ @Mock
+ private HttpResponse commonResponse;
+
+ @Mock
+ private HttpEntity commonEntity;
+
+ @Mock
+ private StatusLine statusLine;
+
+ @Mock
+ private HttpClient httpClient;
+
+ private InputStream postStream;
+
+ private InputStream tokenStream;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ nssmfMgr = new NssmfManager();
+ nssmfMgr.setRestUtil(restUtil);
+ nssmfMgr.setRscOperStatusRepo(rscOperStatusRepo);
+ }
+
+ private void createCommonMock(int statusCode, NssmfInfo nssmf) throws Exception {
+ when(nssmfRest.getNssmfMgr()).thenReturn(nssmfMgr);
+ when(nssmfRest.allocateNssi(any(NssiAllocateRequest.class))).thenCallRealMethod();
+ when(nssmfRest.deAllocateNssi(any(NssiDeAllocateRequest.class), any(String.class))).thenCallRealMethod();
+ when(nssmfRest.activateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod();
+ when(nssmfRest.deactivateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod();
+
+ when(nssmfRest.queryJobStatus(any(JobStatusRequest.class), any(String.class))).thenCallRealMethod();
+ when(restUtil.sendRequest(any(String.class), any(HttpMethod.class), any(String.class), any(EsrInfo.class)))
+ .thenCallRealMethod();
+ when(restUtil.getHttpsClient()).thenReturn(httpClient);
+
+ when(statusLine.getStatusCode()).thenReturn(200);
+ when(restUtil.getNssmfHost(any(EsrInfo.class))).thenReturn(nssmf);
+
+ when(tokenResponse.getEntity()).thenReturn(tokenEntity);
+ when(tokenResponse.getStatusLine()).thenReturn(statusLine);
+ when(tokenEntity.getContent()).thenReturn(tokenStream);
+
+ when(commonResponse.getEntity()).thenReturn(commonEntity);
+ when(commonResponse.getStatusLine()).thenReturn(statusLine);
+ when(commonEntity.getContent()).thenReturn(postStream);
+
+ Answer<HttpResponse> answer = new Answer<HttpResponse>() {
+
+ public HttpResponse answer(InvocationOnMock invocation) throws Throwable {
+ Object[] arguments = invocation.getArguments();
+ if (arguments != null && arguments.length == 1 && arguments[0] != null) {
+
+ HttpRequestBase base = (HttpRequestBase) arguments[0];
+ if (base.getURI().toString().endsWith("/oauth/token")) {
+ return tokenResponse;
+ } else {
+ return commonResponse;
+ }
+ }
+ return commonResponse;
+ }
+ };
+ doAnswer(answer).when(httpClient).execute(any(HttpRequestBase.class));
+ }
+
+ @Test
+ public void testNssiAllocate() throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+ nssiRes.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ createCommonMock(200, nssmf);
+ // assertEquals(prettyPrint(allocateNssi()), ALLOCATE);
+ ResponseEntity res = nssmfRest.allocateNssi(allocateNssi());
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ assertEquals(allRes.getNssiId(), "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ }
+
+ @Test
+ public void testNssiDeAllocate() throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ createCommonMock(200, nssmf);
+ ResponseEntity res = nssmfRest.deAllocateNssi(deAllocateNssi(), "ab9af40f13f721b5f13539d87484098");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ }
+
+ @Test
+ public void testNssiActivate() throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ createCommonMock(200, nssmf);
+ ResponseEntity res = nssmfRest.activateNssi(activateNssi(), "001-100001");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ }
+
+ @Test
+ public void testNssiDeActivate() throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ createCommonMock(200, nssmf);
+ ResponseEntity res = nssmfRest.deactivateNssi(deActivateNssi(), "001-100001");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ }
+
+ @Test
+ public void testAllocateJsonSerDeSer() throws Exception {
+ assertEquals(marshal(allocateNssi()), ALLOCATE);
+ NssiAllocateRequest all = unMarshal(ALLOCATE, NssiAllocateRequest.class);
+ assertNotNull(all);
+ assertNotNull(all.getAllocateCnNssi());
+ assertNotNull(all.getAllocateCnNssi().getSliceProfile());
+ assertEquals(all.getAllocateCnNssi().getSliceProfile().getResourceSharingLevel(), NON_SHARED);
+ assertNotNull(all.getAllocateCnNssi().getSliceProfile().getPerfReq());
+ assertNotNull(all.getAllocateCnNssi().getSliceProfile().getPerfReq().getPerfReqEmbbList());
+ PerfReqEmbbList embb =
+ all.getAllocateCnNssi().getSliceProfile().getPerfReq().getPerfReqEmbbList().iterator().next();
+ assertNotNull(embb);
+ assertEquals(embb.getActivityFactor(), 50);
+ }
+
+ public NssiAllocateRequest allocateNssi() throws Exception {
+ CnSliceProfile sP = new CnSliceProfile();
+ List<String> sns = new LinkedList<>();
+ sns.add("001-100001");
+ List<String> plmn = new LinkedList<>();
+ plmn.add("460-00");
+ plmn.add("460-01");
+ PerfReqEmbbList embb = new PerfReqEmbbList();
+ embb.setActivityFactor(50);
+ List<PerfReqEmbbList> embbList = new LinkedList<>();
+ embbList.add(embb);
+ PerfReq perfReq = new PerfReq();
+ perfReq.setPerfReqEmbbList(embbList);
+ List<String> taList = new LinkedList<>();
+ taList.add("1");
+ taList.add("2");
+ taList.add("3");
+ sP.setSnssaiList(sns);
+ sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098");
+ sP.setPlmnIdList(plmn);
+ sP.setPerfReq(perfReq);
+ sP.setMaxNumberofUEs(200);
+ sP.setCoverageAreaTAList(taList);
+ sP.setLatency(6);
+ sP.setResourceSharingLevel(NON_SHARED);
+ NsiInfo nsiInfo = new NsiInfo();
+ nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ nsiInfo.setNsiName("eMBB-001");
+ AllocateCnNssi cnNssi = new AllocateCnNssi();
+ cnNssi.setNssiId("NSST-C-001-HDBNJ-NSSMF-01-A-ZX");
+ cnNssi.setNssiName("eMBB-001");
+ cnNssi.setScriptName("CN1");
+ cnNssi.setSliceProfile(sP);
+ cnNssi.setNsiInfo(nsiInfo);
+ EsrInfo esrInfo = new EsrInfo();
+ esrInfo.setVendor("huawei");
+ esrInfo.setNetworkType(CORE);
+ NssiAllocateRequest allocate = new NssiAllocateRequest();
+ allocate.setAllocateCnNssi(cnNssi);
+ allocate.setEsrInfo(esrInfo);
+ return allocate;
+ }
+
+ public NssiDeAllocateRequest deAllocateNssi() throws Exception {
+ DeAllocateNssi deAllocateNssi = new DeAllocateNssi();
+ deAllocateNssi.setTerminateNssiOption(0);
+ List<String> snssai = new LinkedList<>();
+ snssai.add("001-100001");
+ deAllocateNssi.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ deAllocateNssi.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ deAllocateNssi.setScriptName("CN1");
+ deAllocateNssi.setSnssaiList(snssai);
+ EsrInfo esrInfo = new EsrInfo();
+ esrInfo.setVendor("huawei");
+ esrInfo.setNetworkType(CORE);
+ NssiDeAllocateRequest deAllocate = new NssiDeAllocateRequest();
+ deAllocate.setDeAllocateNssi(deAllocateNssi);
+ deAllocate.setEsrInfo(esrInfo);
+ return deAllocate;
+ }
+
+ public NssiActDeActRequest activateNssi() throws Exception {
+ EsrInfo esrInfo = new EsrInfo();
+ esrInfo.setVendor("huawei");
+ esrInfo.setNetworkType(CORE);
+ ActDeActNssi act = new ActDeActNssi();
+ act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ NssiActDeActRequest actReq = new NssiActDeActRequest();
+ actReq.setActDeActNssi(act);
+ actReq.setEsrInfo(esrInfo);
+ return actReq;
+ }
+
+ public NssiActDeActRequest deActivateNssi() throws Exception {
+ EsrInfo esrInfo = new EsrInfo();
+ esrInfo.setVendor("huawei");
+ esrInfo.setNetworkType(CORE);
+ ActDeActNssi deAct = new ActDeActNssi();
+ deAct.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ deAct.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ NssiActDeActRequest deActReq = new NssiActDeActRequest();
+ deActReq.setActDeActNssi(deAct);
+ deActReq.setEsrInfo(esrInfo);
+ return deActReq;
+ }
+
+ public String queryJobStatusNssi() throws Exception {
+ EsrInfo esrInfo = new EsrInfo();
+ esrInfo.setVendor("huawei");
+ esrInfo.setNetworkType(CORE);
+
+ JobStatusRequest jobStatus = new JobStatusRequest();
+ jobStatus.setEsrInfo(esrInfo);
+ jobStatus.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ jobStatus.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ return marshal(jobStatus);
+ }
+}