diff options
author | Singal, Kapil (ks220y) <ks220y@att.com> | 2018-08-09 20:47:29 +0000 |
---|---|---|
committer | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-08-10 18:48:54 +0000 |
commit | b35d55e3f57630551f0b773674bd1f5c44585ede (patch) | |
tree | 4429e94ad9ee813ebda5477ad7475a20017e3d62 /ms/controllerblueprints/application/src/main/java |
Controller Blueprints MS
Creating the base directory structure for Controller Blueprints MicroService
Change-Id: I1ccf7fc76446048af3b2822f9155bb634657aee3
Issue-ID: CCSDK-410
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Diffstat (limited to 'ms/controllerblueprints/application/src/main/java')
7 files changed, 354 insertions, 0 deletions
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java new file mode 100644 index 000000000..3172ed38b --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java @@ -0,0 +1,27 @@ +/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints;
+
+/**
+ * ApplicationConstants.java Purpose: Provide ControllerBluprintsApplication Constant Information
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+public final class ApplicationConstants {
+
+}
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java new file mode 100644 index 000000000..96d82e7e4 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java @@ -0,0 +1,38 @@ +/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+/**
+ *
+ *
+ * @author Brinda Santh
+ */
+@SpringBootApplication
+@ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints"})
+@EnableAutoConfiguration
+public class ControllerBluprintsApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ControllerBluprintsApplication.class, args);
+ }
+
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java new file mode 100644 index 000000000..6f4bfc988 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java @@ -0,0 +1,37 @@ +/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+/**
+ *
+ *
+ * @author Brinda Santh
+ */
+@Configuration
+public class ControllerBluprintsFilterConfiguration {
+ private static Logger log = LoggerFactory.getLogger(JerseyConfiguration.class);
+
+ @Value("${server.routingPath:#{null}}")
+ private String routingPath;
+
+
+}
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java new file mode 100644 index 000000000..0d9ab1623 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java @@ -0,0 +1,52 @@ +/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints;
+
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+/**
+ * CorsConfig.java Purpose: Provide Configuration Generator CorsConfig Information
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Configuration
+public class CorsConfig {
+ /**
+ * This is a CORS Implementation for different Orgin GUI to access.
+ *
+ * @return CorsFilter
+ */
+ @Bean
+ public CorsFilter corsFilter() {
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ CorsConfiguration config = new CorsConfiguration();
+ config.setAllowCredentials(true);
+ config.addAllowedOrigin("*");
+ config.addAllowedHeader("*");
+ config.addAllowedMethod("*");
+ source.registerCorsConfiguration("/**", config);
+ return new CorsFilter(source);
+ }
+
+
+}
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java new file mode 100644 index 000000000..5b154ff25 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java @@ -0,0 +1,61 @@ +/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints;
+
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.sql.DataSource;
+
+/**
+ * DatabaseConfig.java Purpose: Provide Configuration Generator DatabaseConfig Information
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Configuration
+@EntityScan("org.onap.ccsdk.apps.controllerblueprints.service.domain")
+@EnableTransactionManagement
+@EnableJpaRepositories("org.onap.ccsdk.apps.controllerblueprints.service.repository")
+@EnableJpaAuditing
+public class DatabaseConfig {
+ /**
+ * This is a entityManagerFactory method
+ *
+ * @param dataSource
+ * @return LocalContainerEntityManagerFactoryBean
+ */
+
+ @Bean
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
+ HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
+ vendorAdapter.setGenerateDdl(true);
+ vendorAdapter.setShowSql(false);
+ LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
+ factory.setJpaVendorAdapter(vendorAdapter);
+ factory.setPackagesToScan("org.onap.ccsdk.apps.controllerblueprints.service.domain");
+ factory.setDataSource(dataSource);
+ return factory;
+ }
+
+}
diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java new file mode 100644 index 000000000..a3b0faf0c --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java @@ -0,0 +1,102 @@ +/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints;
+
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import io.swagger.jaxrs.config.BeanConfig;
+import io.swagger.jaxrs.listing.ApiListingResource;
+import io.swagger.jaxrs.listing.SwaggerSerializers;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.servlet.ServletProperties;
+import org.onap.ccsdk.apps.controllerblueprints.service.common.ServiceExceptionMapper;
+import org.onap.ccsdk.apps.controllerblueprints.service.rs.ConfigModelRestImpl;
+import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestImpl;
+import org.onap.ccsdk.apps.controllerblueprints.service.rs.ResourceDictionaryRestImpl;
+import org.onap.ccsdk.apps.controllerblueprints.service.rs.ServiceTemplateRestImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+import javax.ws.rs.core.MediaType;
+
+/**
+ *
+ *
+ * @author Brinda Santh
+ */
+@Component
+public class JerseyConfiguration extends ResourceConfig {
+ private static Logger log = LoggerFactory.getLogger(JerseyConfiguration.class);
+ /**
+ *
+ */
+ @Autowired
+ public JerseyConfiguration() {
+ register(ConfigModelRestImpl.class);
+ register(ModelTypeRestImpl.class);
+ register(ResourceDictionaryRestImpl.class);
+ register(ServiceTemplateRestImpl.class);
+ register(ServiceExceptionMapper.class);
+ property(ServletProperties.FILTER_FORWARD_ON_404, true);
+ configureSwagger();
+ }
+
+ /**
+ *
+ * @return ObjectMapper
+ */
+ @Bean
+ @Primary
+ public ObjectMapper objectMapper() {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+ objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
+ objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
+ objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
+ return objectMapper;
+ }
+
+ /**
+ *
+ */
+ private void configureSwagger() {
+ register(ApiListingResource.class);
+ register(SwaggerSerializers.class);
+ BeanConfig beanConfig = new BeanConfig();
+ beanConfig.setVersion("1.0.0");
+ beanConfig.setSchemes(new String[]{"http", "https"});
+ beanConfig.setBasePath("/api/controller-blueprints/v1");
+ beanConfig.setTitle("Controller Blueprints API");
+ beanConfig.setDescription("Controller BluePrints API");
+ beanConfig.getSwagger().addConsumes(MediaType.APPLICATION_JSON);
+ beanConfig.getSwagger().addProduces(MediaType.APPLICATION_JSON);
+ beanConfig.setResourcePackage("org.onap.ccsdk.apps.controllerblueprints");
+ beanConfig.setPrettyPrint(true);
+ beanConfig.setScan(true);
+ }
+
+
+}
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java new file mode 100644 index 000000000..a690c056c --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java @@ -0,0 +1,37 @@ +/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+/**
+ *
+ * WebMvcConfiguration WebMvcConfiguration
+ * @author Brinda Santh
+ */
+@Configuration
+@EnableWebMvc
+public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/swagger-ui/dist/");
+ }
+
+}
|