From f42670da77dabfb638c6b180ac7133ec869ecc69 Mon Sep 17 00:00:00 2001 From: da490c Date: Tue, 17 Jul 2018 14:04:07 -0400 Subject: Implement Spring Profile Sparky Config Issue-ID: AAI-1379 Change-Id: I5d56b766f681452abe7e61b307e008bc5a695814 Signed-off-by: da490c --- .../main/java/org/onap/aai/sparky/Application.java | 84 +--------------------- .../org/onap/aai/sparky/aai/FrontEndLayoutApi.java | 2 - .../aai/sparky/camel/FilterAggregationRouter.java | 37 ++++++++++ .../onap/aai/sparky/camel/FilterRequestRouter.java | 37 ++++++++++ .../onap/aai/sparky/camel/GlobalSearchRouter.java | 36 ++++++++++ .../onap/aai/sparky/camel/SubscriptionRouter.java | 37 ++++++++++ .../onap/aai/sparky/camel/ViewInspectRouter.java | 37 ++++++++++ .../onap/aai/sparky/config/CamelConfiguration.java | 19 +++++ .../onap/aai/sparky/config/SparkyConfigLoader.java | 31 -------- .../aai/sparky/config/SparkyHttpConfigLoader.java | 32 --------- .../aai/sparky/config/SparkySslConfigLoader.java | 32 --------- .../org/onap/aai/sparky/portal/PortalBean.java | 41 +++++++++++ 12 files changed, 245 insertions(+), 180 deletions(-) create mode 100644 sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/FilterAggregationRouter.java create mode 100644 sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/FilterRequestRouter.java create mode 100644 sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/GlobalSearchRouter.java create mode 100644 sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/SubscriptionRouter.java create mode 100644 sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/ViewInspectRouter.java create mode 100644 sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/CamelConfiguration.java delete mode 100644 sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyConfigLoader.java delete mode 100644 sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyHttpConfigLoader.java delete mode 100644 sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySslConfigLoader.java create mode 100644 sparkybe-onap-application/src/main/java/org/onap/aai/sparky/portal/PortalBean.java (limited to 'sparkybe-onap-application/src/main/java/org') diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java index 2334297..9958d72 100644 --- a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java +++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/Application.java @@ -20,101 +20,19 @@ */ package org.onap.aai.sparky; -import javax.servlet.Filter; - -import org.apache.camel.component.servlet.CamelHttpTransportServlet; import org.onap.aai.sparky.config.PropertyPasswordConfiguration; -import org.onap.aai.sparky.security.filter.LoginFilter; -import org.openecomp.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.boot.web.servlet.ServletRegistrationBean; -import org.springframework.context.annotation.Bean; @SpringBootApplication public class Application { - private static final String SPARKY_SSL_ENABLED_PROPERTY = "sparky.ssl.enabled"; - private static final String SPARKY_PORTAL_ENABLED_PROPERTY = "sparky.portal.enabled"; - private static final String SPARKY_SSL_ENABLED_ENV = "SPARKY_SSL_ENABLED"; - private static final String SPARKY_PORTAL_ENABLED_ENV = "SPARKY_PORTAL_ENABLED"; - - private Filter loginFilter = new LoginFilter(); - public static void main(String[] args) { - setDefaultProperties(); SpringApplication app = new SpringApplication(Application.class); app.addInitializers(new PropertyPasswordConfiguration()); app.run(args); } - - protected static void setDefaultProperties() { - - /* - * By default we want ssl and portal integration, however it is possible to turn these off with - * properties for local development and interop in some situations. - */ - - if (System.getenv(SPARKY_SSL_ENABLED_ENV) == null) { - System.setProperty(SPARKY_SSL_ENABLED_PROPERTY, "true"); - } else { - System.setProperty(SPARKY_SSL_ENABLED_PROPERTY, System.getenv(SPARKY_SSL_ENABLED_ENV)); - } - - boolean sslEnabled = Boolean.parseBoolean(System.getProperty(SPARKY_SSL_ENABLED_PROPERTY)); - - if (sslEnabled) { - System.setProperty("server.ssl.key-store-password", System.getenv("KEYSTORE_PASSWORD")); - System.setProperty("server.ssl.key-password", System.getenv("KEYSTORE_ALIAS_PASSWORD")); - } - - if (System.getenv(SPARKY_PORTAL_ENABLED_ENV) == null) { - System.setProperty(SPARKY_PORTAL_ENABLED_PROPERTY, "true"); - } else { - System.setProperty(SPARKY_PORTAL_ENABLED_PROPERTY, System.getenv(SPARKY_PORTAL_ENABLED_ENV)); - } - } - - /* - * This initialization code enabled access to aai-ui-proxy-processor - */ - @Bean - ServletRegistrationBean servletRegistrationBean() { - final ServletRegistrationBean servlet = - new ServletRegistrationBean(new CamelHttpTransportServlet(), "/rest/*"); - servlet.setName("CamelServlet"); - return servlet; - } - - /** - * bind LoginFilter - */ - @Bean - @ConditionalOnProperty(value = "sparky.portal.enabled", havingValue = "true") - public FilterRegistrationBean loginFilterRegistrationBean() { - FilterRegistrationBean registration = new FilterRegistrationBean(); - - registration.setFilter(loginFilter); - registration.addUrlPatterns("/*"); - - return registration; - } - - /** - * Bind the Portal API Proxy - */ - @Bean - @ConditionalOnProperty(value = "sparky.portal.enabled", havingValue = "true") - public ServletRegistrationBean portalApiProxy() { - - final ServletRegistrationBean servlet = - new ServletRegistrationBean(new PortalRestAPIProxy(), "/api/v2/*"); - servlet.setName("PortalRestApiProxy"); - return servlet; - } - + } diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/aai/FrontEndLayoutApi.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/aai/FrontEndLayoutApi.java index 0590cd6..ab74074 100644 --- a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/aai/FrontEndLayoutApi.java +++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/aai/FrontEndLayoutApi.java @@ -31,9 +31,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; @RestController public class FrontEndLayoutApi { - public FrontEndLayoutApi() { - } @RequestMapping(value = "/layouts", method = {RequestMethod.GET}) diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/FilterAggregationRouter.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/FilterAggregationRouter.java new file mode 100644 index 0000000..634dcc5 --- /dev/null +++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/FilterAggregationRouter.java @@ -0,0 +1,37 @@ +/** + * ============LICENSE_START======================================================= + * SPARKY (AAI UI service) + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.sparky.camel; + +import org.apache.camel.spring.SpringRouteBuilder; +import org.springframework.stereotype.Component; + +@Component +public class FilterAggregationRouter extends SpringRouteBuilder { + + @Override + public void configure() throws Exception { + + rest().post("/search/filterAggregation") + .to("bean:aggregateSummaryProcessor?method=getFilteredAggregation"); + + } + +} diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/FilterRequestRouter.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/FilterRequestRouter.java new file mode 100644 index 0000000..849f013 --- /dev/null +++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/FilterRequestRouter.java @@ -0,0 +1,37 @@ +/** + * ============LICENSE_START======================================================= + * SPARKY (AAI UI service) + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.sparky.camel; + +import org.apache.camel.spring.SpringRouteBuilder; +import org.springframework.stereotype.Component; + +@Component +public class FilterRequestRouter extends SpringRouteBuilder { + + @Override + public void configure() throws Exception { + + rest().post("/search/unifiedFilterRequest") + .to("bean:filterProcessor?method=getFiltersWithValues"); + + } + +} diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/GlobalSearchRouter.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/GlobalSearchRouter.java new file mode 100644 index 0000000..ea87254 --- /dev/null +++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/GlobalSearchRouter.java @@ -0,0 +1,36 @@ +/** + * ============LICENSE_START======================================================= + * SPARKY (AAI UI service) + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.sparky.camel; + +import org.apache.camel.spring.SpringRouteBuilder; +import org.springframework.stereotype.Component; + +@Component +public class GlobalSearchRouter extends SpringRouteBuilder { + + @Override + public void configure() throws Exception { + + rest().post("/search/querysearch").to("bean:unifiedSearchProcessor?method=search"); + + } + +} diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/SubscriptionRouter.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/SubscriptionRouter.java new file mode 100644 index 0000000..4a28e30 --- /dev/null +++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/SubscriptionRouter.java @@ -0,0 +1,37 @@ +/** + * ============LICENSE_START======================================================= + * SPARKY (AAI UI service) + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.sparky.camel; + +import org.apache.camel.spring.SpringRouteBuilder; +import org.springframework.stereotype.Component; + +@Component +public class SubscriptionRouter extends SpringRouteBuilder { + + @Override + public void configure() throws Exception { + + rest().get("/subscription/getsubscription") + .to("bean:subscriptionServiceProcessor?method=getSubscription"); + + } + +} diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/ViewInspectRouter.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/ViewInspectRouter.java new file mode 100644 index 0000000..ee2ae04 --- /dev/null +++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/ViewInspectRouter.java @@ -0,0 +1,37 @@ +/** + * ============LICENSE_START======================================================= + * SPARKY (AAI UI service) + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.sparky.camel; + +import org.apache.camel.spring.SpringRouteBuilder; +import org.springframework.stereotype.Component; + +@Component +public class ViewInspectRouter extends SpringRouteBuilder { + + @Override + public void configure() throws Exception { + + rest().post("/visualization/prepareVisualization").route() + .to("bean:schemaVisualizationProcessor?method=processVisualizationRequest"); + + } + +} diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/CamelConfiguration.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/CamelConfiguration.java new file mode 100644 index 0000000..8f433db --- /dev/null +++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/CamelConfiguration.java @@ -0,0 +1,19 @@ +package org.onap.aai.sparky.config; + +import org.apache.camel.component.servlet.CamelHttpTransportServlet; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +@Component +public class CamelConfiguration { + + @Bean + ServletRegistrationBean servletRegistrationBean() { + final ServletRegistrationBean servlet = + new ServletRegistrationBean(new CamelHttpTransportServlet(), "/rest/*", "/services/*"); + servlet.setName("CamelServlet"); + return servlet; + } + +} \ No newline at end of file diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyConfigLoader.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyConfigLoader.java deleted file mode 100644 index 5124ce7..0000000 --- a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyConfigLoader.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.aai.sparky.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@PropertySource("file:${CONFIG_HOME}/sparky-application.properties") -public class SparkyConfigLoader { - - -} diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyHttpConfigLoader.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyHttpConfigLoader.java deleted file mode 100644 index f6b739c..0000000 --- a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkyHttpConfigLoader.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.aai.sparky.config; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@ConditionalOnProperty(value="sparky.ssl.enabled", havingValue = "false") -@PropertySource("file:${CONFIG_HOME}/sparky-http-config.properties") -public class SparkyHttpConfigLoader { - -} diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySslConfigLoader.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySslConfigLoader.java deleted file mode 100644 index c216ddd..0000000 --- a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/config/SparkySslConfigLoader.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.aai.sparky.config; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@ConditionalOnProperty(value="sparky.ssl.enabled", havingValue = "true") -@PropertySource("file:${CONFIG_HOME}/sparky-ssl-config.properties") -public class SparkySslConfigLoader { - -} diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/portal/PortalBean.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/portal/PortalBean.java new file mode 100644 index 0000000..86f019e --- /dev/null +++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/portal/PortalBean.java @@ -0,0 +1,41 @@ +package org.onap.aai.sparky.portal; + +import javax.servlet.Filter; + +import org.onap.aai.sparky.security.filter.LoginFilter; +import org.openecomp.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +@Component +@Profile("portal") +public class PortalBean { + + private Filter loginFilter = new LoginFilter(); + + /** + * bind LoginFilter + */ + @Bean + public FilterRegistrationBean loginFilterRegistrationBean() { + FilterRegistrationBean registration = new FilterRegistrationBean(); + + registration.setFilter(loginFilter); + registration.addUrlPatterns("/*"); + + return registration; + } + + @Bean + public ServletRegistrationBean portalApiProxy() { + + final ServletRegistrationBean servlet = + new ServletRegistrationBean(new PortalRestAPIProxy(), "/api/v2/*"); + servlet.setName("PortalRestApiProxy"); + return servlet; + } + +} \ No newline at end of file -- cgit 1.2.3-korg