diff options
author | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-03-25 13:04:18 -0400 |
---|---|---|
committer | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-03-25 13:41:44 -0400 |
commit | c90edac236dffb7c495e266dd04991de7e8f04b7 (patch) | |
tree | 103bb4d0870101ff61442f6b0fe291d1ad53b950 /ms/controllerblueprints/application | |
parent | ffb6bdfd6de2afa23d95d0884c9db4059982deed (diff) |
Migrate ccsdk/apps to ccsdk/cds
Issue-ID: CCSDK-1177
Issue-ID: CCSDK-1178
Change-Id: I0c02702fbec52211ca367abbba72aebecee8cbaa
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/controllerblueprints/application')
15 files changed, 351 insertions, 351 deletions
diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index 4a7335496..3bb7fde9a 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -19,7 +19,7 @@ <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.ccsdk.apps.controllerblueprints</groupId> + <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> <artifactId>parent</artifactId> <version>0.4.2-SNAPSHOT</version> <relativePath>../parent</relativePath> @@ -29,7 +29,7 @@ <properties> <swagger.directory>${basedir}/target/src/main/resources/swagger-ui</swagger.directory> <java.version>1.8</java.version> - <name.space>org.onap.ccsdk.apps</name.space> <!-- <name.space>${namespace}</name.space> --> + <name.space>org.onap.ccsdk.cds</name.space> <!-- <name.space>${namespace}</name.space> --> <serviceArtifactName>controllerblueprints</serviceArtifactName> <!-- Sonar --> <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin> @@ -46,7 +46,7 @@ <dependencies> <dependency> - <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> + <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> <artifactId>service</artifactId> </dependency> <dependency> @@ -208,7 +208,7 @@ <apiSources> <apiSource> <springmvc>true</springmvc> - <locations>org.onap.ccsdk.apps.controllerblueprints.service.rs + <locations>org.onap.ccsdk.cds.controllerblueprints.service.rs </locations> <schemes> <scheme>http</scheme> 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/cds/controllerblueprints/ApplicationConstants.java index c4759b568..9a9fafffc 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ApplicationConstants.java @@ -1,28 +1,28 @@ -/*
- * 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 ControllerBlueprintsApplication Constant Information
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@SuppressWarnings("unused")
-public final class ApplicationConstants {
-
-}
+/* + * 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.cds.controllerblueprints; + +/** + * ApplicationConstants.java Purpose: Provide ControllerBlueprintsApplication Constant Information + * + * @author Brinda Santh + * @version 1.0 + */ +@SuppressWarnings("unused") +public final class ApplicationConstants { + +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplication.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ControllerBlueprintsApplication.java index e925c69c0..29d2eb7c7 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplication.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ControllerBlueprintsApplication.java @@ -1,42 +1,42 @@ -/*
- * 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.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.web.reactive.config.EnableWebFlux;
-
-/**
- * @author Brinda Santh
- */
-@SpringBootApplication
-@EnableWebFlux
-@ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints"})
-@EnableAutoConfiguration
-public class ControllerBlueprintsApplication {
- private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBlueprintsApplication.class);
-
- public static void main(String[] args) {
- log.info("****** Starting Controlled Blueprints Application ******");
- SpringApplication.run(ControllerBlueprintsApplication.class, args);
- }
-
+/* + * 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.cds.controllerblueprints; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.web.reactive.config.EnableWebFlux; + +/** + * @author Brinda Santh + */ +@SpringBootApplication +@EnableWebFlux +@ComponentScan(basePackages = {"org.onap.ccsdk.cds.controllerblueprints"}) +@EnableAutoConfiguration +public class ControllerBlueprintsApplication { + private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBlueprintsApplication.class); + + public static void main(String[] args) { + log.info("****** Starting Controlled Blueprints Application ******"); + SpringApplication.run(ControllerBlueprintsApplication.class, args); + } + }
\ No newline at end of file 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/cds/controllerblueprints/DatabaseConfig.java index 5b154ff25..8ec4bd4a3 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/DatabaseConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/DatabaseConfig.java @@ -1,61 +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;
- }
-
-}
+/* + * 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.cds.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.cds.controllerblueprints.service.domain") +@EnableTransactionManagement +@EnableJpaRepositories("org.onap.ccsdk.cds.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.cds.controllerblueprints.service.domain"); + factory.setDataSource(dataSource); + return factory; + } + +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/SwaggerConfig.java index ca6332833..93182769b 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/SwaggerConfig.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.onap.ccsdk.apps.controllerblueprints; +package org.onap.ccsdk.cds.controllerblueprints; import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.http.HttpStatus; diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/WebConfig.java index 45faa1b57..e4799bc84 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/WebConfig.java @@ -1,50 +1,50 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- * 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.reactive.config.CorsRegistry;
-import org.springframework.web.reactive.config.ResourceHandlerRegistry;
-import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
-
-/**
- * WebConfig
- *
- * @author Brinda Santh 8/13/2018
- */
-@Configuration
-@SuppressWarnings("unused")
-public class WebConfig extends WebFluxConfigurationSupport {
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.addResourceHandler("swagger-ui.html")
- .addResourceLocations("classpath:/META-INF/resources/");
-
- registry.addResourceHandler("/webjars/**")
- .addResourceLocations("classpath:/META-INF/resources/webjars/");
-
- }
-
- @Override
- public void addCorsMappings(CorsRegistry corsRegistry) {
- corsRegistry.addMapping("/**")
- .allowedOrigins("*")
- .allowedMethods("*")
- .allowedHeaders("DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range")
- .maxAge(3600);
- }
-}
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * 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.cds.controllerblueprints; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.config.CorsRegistry; +import org.springframework.web.reactive.config.ResourceHandlerRegistry; +import org.springframework.web.reactive.config.WebFluxConfigurationSupport; + +/** + * WebConfig + * + * @author Brinda Santh 8/13/2018 + */ +@Configuration +@SuppressWarnings("unused") +public class WebConfig extends WebFluxConfigurationSupport { + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + + } + + @Override + public void addCorsMappings(CorsRegistry corsRegistry) { + corsRegistry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range") + .maxAge(3600); + } +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/filters/ApplicationLoggingFilter.java index 367ea7d91..60837e8a7 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/filters/ApplicationLoggingFilter.java @@ -1,98 +1,98 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.filters;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.server.reactive.ServerHttpRequest;
-import org.springframework.http.server.reactive.ServerHttpResponse;
-import org.springframework.web.server.ServerWebExchange;
-import org.springframework.web.server.WebFilter;
-import org.springframework.web.server.WebFilterChain;
-import reactor.core.publisher.Mono;
-
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.UUID;
-
-/**
- * ApplicationLoggingFilter
- *
- * @author Brinda Santh 8/14/2018
- */
-@Configuration
-@SuppressWarnings("unused")
-public class ApplicationLoggingFilter implements WebFilter {
- private static Logger log = LoggerFactory.getLogger(ApplicationLoggingFilter.class);
-
- @SuppressWarnings("unused")
- @Value("${appVersion}")
- private String appVersion;
-
- @Override
- public Mono<Void> filter(ServerWebExchange serverWebExchange, WebFilterChain webFilterChain) {
- try {
-
- ServerHttpRequest request = serverWebExchange.getRequest();
- ServerHttpResponse response = serverWebExchange.getResponse();
-
- String[] tokens = StringUtils.split(appVersion, '.');
- Preconditions.checkNotNull(tokens, "failed to split application versions");
- Preconditions.checkArgument(tokens.length == 3, "failed to tokenize application versions");
- HttpHeaders header = response.getHeaders();
-
- String requestID = defaultToUUID(request.getHeaders().getFirst("X-ONAP-RequestID"));
- String invocationID = defaultToUUID(request.getHeaders().getFirst("X-ONAP-InvocationID"));
- String partnerName = defaultToEmpty(request.getHeaders().getFirst("X-ONAP-PartnerName"));
- MDC.put("InvokeTimestamp", ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
- MDC.put("RequestID", requestID);
- MDC.put("InvocationID", invocationID);
- MDC.put("PartnerName", partnerName);
- MDC.put("ClientIPAddress", defaultToEmpty(request.getRemoteAddress().getAddress()));
- MDC.put("ServerFQDN", defaultToEmpty(request.getRemoteAddress().getHostString()));
-
- header.add(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, requestID);
- header.add(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, tokens[1]);
- header.add(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, tokens[2]);
- header.add(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, appVersion);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return webFilterChain.filter(serverWebExchange);
-
- }
-
- private static String defaultToUUID(String in) {
- return in == null ? UUID.randomUUID().toString() : in;
- }
-
- private static String defaultToEmpty(Object in) {
- return in == null ? "" : in.toString();
- }
-
-
+/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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.cds.controllerblueprints.filters; + +import com.google.common.base.Preconditions; +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpHeaders; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.server.WebFilter; +import org.springframework.web.server.WebFilterChain; +import reactor.core.publisher.Mono; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.UUID; + +/** + * ApplicationLoggingFilter + * + * @author Brinda Santh 8/14/2018 + */ +@Configuration +@SuppressWarnings("unused") +public class ApplicationLoggingFilter implements WebFilter { + private static Logger log = LoggerFactory.getLogger(ApplicationLoggingFilter.class); + + @SuppressWarnings("unused") + @Value("${appVersion}") + private String appVersion; + + @Override + public Mono<Void> filter(ServerWebExchange serverWebExchange, WebFilterChain webFilterChain) { + try { + + ServerHttpRequest request = serverWebExchange.getRequest(); + ServerHttpResponse response = serverWebExchange.getResponse(); + + String[] tokens = StringUtils.split(appVersion, '.'); + Preconditions.checkNotNull(tokens, "failed to split application versions"); + Preconditions.checkArgument(tokens.length == 3, "failed to tokenize application versions"); + HttpHeaders header = response.getHeaders(); + + String requestID = defaultToUUID(request.getHeaders().getFirst("X-ONAP-RequestID")); + String invocationID = defaultToUUID(request.getHeaders().getFirst("X-ONAP-InvocationID")); + String partnerName = defaultToEmpty(request.getHeaders().getFirst("X-ONAP-PartnerName")); + MDC.put("InvokeTimestamp", ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)); + MDC.put("RequestID", requestID); + MDC.put("InvocationID", invocationID); + MDC.put("PartnerName", partnerName); + MDC.put("ClientIPAddress", defaultToEmpty(request.getRemoteAddress().getAddress())); + MDC.put("ServerFQDN", defaultToEmpty(request.getRemoteAddress().getHostString())); + + header.add(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, requestID); + header.add(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, tokens[1]); + header.add(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, tokens[2]); + header.add(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, appVersion); + } catch (Exception e) { + e.printStackTrace(); + } + + return webFilterChain.filter(serverWebExchange); + + } + + private static String defaultToUUID(String in) { + return in == null ? UUID.randomUUID().toString() : in; + } + + private static String defaultToEmpty(Object in) { + return in == null ? "" : in.toString(); + } + + }
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java index 334574f79..131ff015d 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java @@ -1,62 +1,62 @@ -/*
- * 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.security;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
-import org.springframework.security.config.web.server.ServerHttpSecurity;
-import org.springframework.security.core.userdetails.MapReactiveUserDetailsService;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.web.server.SecurityWebFilterChain;
-
-@SuppressWarnings("unused")
-@EnableWebFluxSecurity
-public class ApplicationSecurityConfigurerAdapter {
-
- @Value("${basic-auth.user-name}")
- private String userName;
-
- @Value("${basic-auth.hashed-pwd}")
- private String userHashedPassword;
-
- private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationSecurityConfigurerAdapter.class);
-
- @Bean
- public SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception {
-
- http.csrf().disable();
- http.authorizeExchange()
- .pathMatchers("/webjars/**", "/actuator/**").permitAll()
- .anyExchange().authenticated()
- .and().httpBasic();
-
- return http.build();
- }
-
- @Bean
- public MapReactiveUserDetailsService userDetailsService() {
- User.UserBuilder userBuilder = User.builder();
- UserDetails defaultUser = userBuilder
- .username(userName)
- .password(userHashedPassword).roles("USER").build();
- return new MapReactiveUserDetailsService(defaultUser);
- }
+/* + * 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.cds.controllerblueprints.security; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; +import org.springframework.security.config.web.server.ServerHttpSecurity; +import org.springframework.security.core.userdetails.MapReactiveUserDetailsService; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.web.server.SecurityWebFilterChain; + +@SuppressWarnings("unused") +@EnableWebFluxSecurity +public class ApplicationSecurityConfigurerAdapter { + + @Value("${basic-auth.user-name}") + private String userName; + + @Value("${basic-auth.hashed-pwd}") + private String userHashedPassword; + + private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationSecurityConfigurerAdapter.class); + + @Bean + public SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception { + + http.csrf().disable(); + http.authorizeExchange() + .pathMatchers("/webjars/**", "/actuator/**").permitAll() + .anyExchange().authenticated() + .and().httpBasic(); + + return http.build(); + } + + @Bean + public MapReactiveUserDetailsService userDetailsService() { + User.UserBuilder userBuilder = User.builder(); + UserDetails defaultUser = userBuilder + .username(userName) + .password(userHashedPassword).roles("USER").build(); + return new MapReactiveUserDetailsService(defaultUser); + } }
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/resources/application-dev.properties b/ms/controllerblueprints/application/src/main/resources/application-dev.properties index 3401ece04..7282d75c4 100755 --- a/ms/controllerblueprints/application/src/main/resources/application-dev.properties +++ b/ms/controllerblueprints/application/src/main/resources/application-dev.properties @@ -14,7 +14,7 @@ # limitations under the License. # appName=ControllerBluePrints -ms_name=org.onap.ccsdk.apps.controllerblueprints +ms_name=org.onap.ccsdk.cds.controllerblueprints appVersion=1.0.0 # Basic Authentication diff --git a/ms/controllerblueprints/application/src/main/resources/application.properties b/ms/controllerblueprints/application/src/main/resources/application.properties index 8789c24ec..5877ea55a 100755 --- a/ms/controllerblueprints/application/src/main/resources/application.properties +++ b/ms/controllerblueprints/application/src/main/resources/application.properties @@ -16,7 +16,7 @@ # limitations under the License. # appName=ControllerBluePrints -ms_name=org.onap.ccsdk.apps.controllerblueprints +ms_name=org.onap.ccsdk.cds.controllerblueprints appVersion=1.0.0 # Basic Authentication diff --git a/ms/controllerblueprints/application/src/main/resources/logback.xml b/ms/controllerblueprints/application/src/main/resources/logback.xml index 2db82a128..2af5a92cc 100644 --- a/ms/controllerblueprints/application/src/main/resources/logback.xml +++ b/ms/controllerblueprints/application/src/main/resources/logback.xml @@ -35,7 +35,7 @@ <logger name="org.springframework.web" level="info"/> <logger name="org.springframework.security.web.authentication" level="warn"/> <logger name="org.hibernate" level="error"/> - <logger name="org.onap.ccsdk.apps" level="info"/> + <logger name="org.onap.ccsdk.cds" level="info"/> <root level="warn"> <appender-ref ref="STDOUT"/> diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplicationTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplicationTest.java index cf9b3e71f..0b9df88b8 100644 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplicationTest.java +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplicationTest.java @@ -14,7 +14,7 @@ * limitations under the License.
*/
-package org.onap.ccsdk.apps.controllerblueprints;
+package org.onap.ccsdk.cds.controllerblueprints;
import org.junit.Before;
import org.junit.Test;
diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java index 995644fd0..71597afc4 100644 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java @@ -14,7 +14,7 @@ * limitations under the License.
*/
-package org.onap.ccsdk.apps.controllerblueprints;
+package org.onap.ccsdk.cds.controllerblueprints;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index 8ad9f2c09..5d970a0a6 100755 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -17,7 +17,7 @@ spring.main.banner-mode=off
appName=ControllerBluePrints
-ms_name=org.onap.ccsdk.apps.controllerblueprints
+ms_name=org.onap.ccsdk.cds.controllerblueprints
appVersion=1.0.0
# Basic Authentication
diff --git a/ms/controllerblueprints/application/src/test/resources/logback.xml b/ms/controllerblueprints/application/src/test/resources/logback.xml index 53388bc9e..55b008d11 100644 --- a/ms/controllerblueprints/application/src/test/resources/logback.xml +++ b/ms/controllerblueprints/application/src/test/resources/logback.xml @@ -26,7 +26,7 @@ <logger name="org.springframework" level="warn"/>
<logger name="org.hibernate" level="info"/>
- <logger name="org.onap.ccsdk.apps.controllerblueprints" level="info"/>
+ <logger name="org.onap.ccsdk.cds.controllerblueprints" level="info"/>
<root level="warn">
<appender-ref ref="STDOUT"/>
|