aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-vfc-adapter/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-vfc-adapter/src/main')
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java91
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/MSOVfcApplication.java (renamed from adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/MSOVfcApplication.java)5
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/RequestDBConfig.java80
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/JerseyConfiguration.java60
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/AaiUtil.java (renamed from adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/AaiUtil.java)2
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java (renamed from adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/HealthCheckHandler.java)2
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java (renamed from adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcAdapterRest.java)3
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcManager.java (renamed from adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcManager.java)28
-rw-r--r--adapters/mso-vfc-adapter/src/main/resources/application-local.yaml34
-rw-r--r--adapters/mso-vfc-adapter/src/main/resources/application.yaml53
10 files changed, 248 insertions, 110 deletions
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java
new file mode 100644
index 0000000000..3034cbcac3
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.vfc;
+
+import java.util.Arrays;
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.LoggingFeature;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.transport.servlet.CXFServlet;
+import org.onap.so.adapters.vfc.rest.HealthCheckHandler;
+import org.onap.so.adapters.vfc.rest.VfcAdapterRest;
+import org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+
+
+@Configuration
+public class CXFConfiguration {
+
+ @Autowired
+ private Bus bus;
+
+ @Autowired
+ private VfcAdapterRest vfcAdapterRest;
+
+ @Autowired
+ private HealthCheckHandler healthCheckHandler;
+
+ @Autowired
+ private JaxRsFilterLogging jaxRsFilterLogging;
+
+ @Autowired
+ private ObjectMapper mapper;
+
+ @Bean
+ public ServletRegistrationBean cxfServlet() {
+ return new ServletRegistrationBean(new CXFServlet(), "/services/*");
+ }
+
+ @Bean
+ public Server rsServer() {
+ JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
+ endpoint.setBus(bus);
+ endpoint.setServiceBeans(Arrays.<Object>asList(vfcAdapterRest, healthCheckHandler));
+ endpoint.setAddress("/");
+ endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature()));
+ endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper),jaxRsFilterLogging));
+ return endpoint.create();
+ }
+
+ @Bean
+ public Swagger2Feature createSwaggerFeature() {
+ Swagger2Feature swagger2Feature = new Swagger2Feature();
+ swagger2Feature.setPrettyPrint(true);
+ swagger2Feature.setTitle("SO Request Adapter");
+ swagger2Feature.setContact("The ONAP SO team");
+ swagger2Feature.setDescription("This project is the SO Orchestration Engine");
+ swagger2Feature.setVersion("1.0.0");
+ swagger2Feature.setResourcePackage("org.onap.so.adapters.requestdb");
+ swagger2Feature.setScan(true);
+ return swagger2Feature;
+ }
+
+}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/MSOVfcApplication.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/MSOVfcApplication.java
index c6d141391d..5bb83a7c1b 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/MSOVfcApplication.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/MSOVfcApplication.java
@@ -18,19 +18,18 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.vfc.application;
+package org.onap.so.adapters.vfc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication(scanBasePackages = {"org.onap.so"})
-@EnableJpaRepositories({"org.onap.so.db.request.data.repository"})
-@EntityScan({"org.onap.so.db.request.beans"})
public class MSOVfcApplication {
public static void main(String... args) {
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/RequestDBConfig.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/RequestDBConfig.java
new file mode 100644
index 0000000000..2ff66d2c25
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/RequestDBConfig.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.vfc;
+
+
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+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-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/JerseyConfiguration.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/JerseyConfiguration.java
deleted file mode 100644
index a97549189d..0000000000
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/JerseyConfiguration.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.vfc.application;
-
-import javax.annotation.PostConstruct;
-import javax.ws.rs.ApplicationPath;
-
-import org.glassfish.jersey.server.ResourceConfig;
-import org.onap.so.adapters.vfc.HealthCheckHandler;
-import org.onap.so.adapters.vfc.VfcAdapterRest;
-import org.springframework.context.annotation.Configuration;
-
-import io.swagger.jaxrs.config.BeanConfig;
-import io.swagger.jaxrs.listing.ApiListingResource;
-import io.swagger.jaxrs.listing.SwaggerSerializers;
-
-@Configuration
-@ApplicationPath("/vfc")
-public class JerseyConfiguration extends ResourceConfig {
-
- public JerseyConfiguration() {
-
- }
-
- @PostConstruct
- public void setUp() {
- register(VfcAdapterRest.class);
- register(HealthCheckHandler.class);
-
- this.register(ApiListingResource.class);
- this.register(SwaggerSerializers.class);
-
- BeanConfig beanConfig = new BeanConfig();
- beanConfig.setVersion("1.0.2");
- beanConfig.setSchemes(new String[] { "http" });
- beanConfig.setHost("localhost:8080");
- beanConfig.setBasePath("/");
- beanConfig.setResourcePackage("org.onap.so.adapters.vfc.application");
- beanConfig.setPrettyPrint(true);
- beanConfig.setScan(true);
- }
-}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/AaiUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/AaiUtil.java
index a4f05158a8..6ae2ba0aca 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/AaiUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/AaiUtil.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.vfc;
+package org.onap.so.adapters.vfc.rest;
import org.onap.so.adapters.vfc.model.RestfulResponse;
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/HealthCheckHandler.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java
index 8fcf315641..c39a165338 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/HealthCheckHandler.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/HealthCheckHandler.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.vfc;
+package org.onap.so.adapters.vfc.rest;
import javax.ws.rs.HEAD;
import javax.ws.rs.Path;
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcAdapterRest.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java
index e07753b33a..9489ef14f5 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcAdapterRest.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.vfc;
+package org.onap.so.adapters.vfc.rest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -28,7 +28,6 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-
import org.onap.so.adapters.vfc.exceptions.ApplicationException;
import org.onap.so.adapters.vfc.model.NSResourceInputParameter;
import org.onap.so.adapters.vfc.model.NsOperationKey;
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcManager.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcManager.java
index 47d3842c03..2dbc444bc3 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcManager.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcManager.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.vfc;
+package org.onap.so.adapters.vfc.rest;
import java.util.HashMap;
import java.util.Map;
@@ -48,6 +48,7 @@ import org.onap.so.requestsdb.RequestsDbConstant;
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;
@@ -60,6 +61,7 @@ import org.springframework.stereotype.Component;
* @version ONAP Amsterdam Release 2017-08-28
*/
@Component
+@Primary
public class VfcManager {
private static final Logger LOGGER = LoggerFactory.getLogger(VfcManager.class);
@@ -67,25 +69,23 @@ public class VfcManager {
/**
* nfvo url map
*/
- private static Map<String, String> nfvoUrlMap;
+ private Map<String, String> nfvoUrlMap;
+
@Autowired
private ResourceOperationStatusRepository resourceOperationStatusRepository;
@Autowired
private RestfulUtil restfulUtil;
- static {
- nfvoUrlMap = new HashMap<>();
- nfvoUrlMap.put(Step.CREATE, CommonConstant.NFVO_CREATE_URL);
- nfvoUrlMap.put(Step.INSTANTIATE, CommonConstant.NFVO_INSTANTIATE_URL);
- nfvoUrlMap.put(Step.TERMINATE, CommonConstant.NFVO_TERMINATE_URL);
- nfvoUrlMap.put(Step.DELETE, CommonConstant.NFVO_DELETE_URL);
- nfvoUrlMap.put(Step.QUERY, CommonConstant.NFVO_QUERY_URL);
- nfvoUrlMap.put(Step.SCALE, CommonConstant.NFVO_SCALE_URL);
- }
-
- public VfcManager() {
-
+
+ public VfcManager() {
+ nfvoUrlMap = new HashMap<>();
+ nfvoUrlMap.put(Step.CREATE, CommonConstant.NFVO_CREATE_URL);
+ nfvoUrlMap.put(Step.INSTANTIATE, CommonConstant.NFVO_INSTANTIATE_URL);
+ nfvoUrlMap.put(Step.TERMINATE, CommonConstant.NFVO_TERMINATE_URL);
+ nfvoUrlMap.put(Step.DELETE, CommonConstant.NFVO_DELETE_URL);
+ nfvoUrlMap.put(Step.QUERY, CommonConstant.NFVO_QUERY_URL);
+ nfvoUrlMap.put(Step.SCALE, CommonConstant.NFVO_SCALE_URL);
}
/**
diff --git a/adapters/mso-vfc-adapter/src/main/resources/application-local.yaml b/adapters/mso-vfc-adapter/src/main/resources/application-local.yaml
new file mode 100644
index 0000000000..0519f50c46
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/resources/application-local.yaml
@@ -0,0 +1,34 @@
+server:
+ port: 8091
+ tomcat:
+ max-threads: 50
+ssl-enable: false
+mso:
+ logPath: logs
+ site-name: localSite
+spring:
+ datasource:
+ url: jdbc:mariadb://localhost:3306/requestdb
+ username: mso
+ password: mso123
+ driver-class-name: org.mariadb.jdbc.Driver
+ initialize: true
+ initialization-mode: never
+ jpa:
+ generate-ddl: false
+ show-sql: false
+ hibernate:
+ ddl-auto: validate
+ naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+ enable-lazy-load-no-trans: true
+ database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+ security:
+ usercredentials:
+ -
+ username: bpel
+ password: '$2a$12$1xyutEZNfjGewIZRfKaE8eZE99f5sYFUmmM80BobI65KNjmcK0JuO'
+ role: BPEL-Client
+ -
+ username: mso_admin
+ password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa'
+ role: ACTUATOR
diff --git a/adapters/mso-vfc-adapter/src/main/resources/application.yaml b/adapters/mso-vfc-adapter/src/main/resources/application.yaml
index ba574ba3e9..2cee9cf7dc 100644
--- a/adapters/mso-vfc-adapter/src/main/resources/application.yaml
+++ b/adapters/mso-vfc-adapter/src/main/resources/application.yaml
@@ -1,37 +1,32 @@
-logging:
- path: logs
-
-# H2
-spring:
- datasource:
- url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;
- username: sa
- password: sa
- driver-class-name: org.h2.Driver
- intialize: true
- h2:
- console:
- enabled: true
- path: /h2
server:
port: 8080
tomcat:
max-threads: 50
-mso:
- site-name: localSite
-#Actuator
-management:
- security:
- enabled: false
- basic:
- enabled: false
- metrics:
- se-global-registry: false
- export:
- prometheus:
- enabled: true # Whether exporting of metrics to Prometheus is enabled.
- step: 1m # Step size (i.e. reporting frequency) to use.
+mso:
+ site-name: unknown
+ logPath: ./logs/vfc/
+spring:
+ datasource:
+ url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/requestdb
+ username: ${DB_USERNAME}
+ password: ${DB_PASSWORD}
+ driver-class-name: org.mariadb.jdbc.Driver
+ dbcp2:
+ initial-size: 5
+ max-total: 20
+ validation-query: select 1
+ test-on-borrow: true
+ 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
+#Actuator
+management:
+ context-path: /manage