2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
21 package org.onap.portalapp.conf;
23 import java.util.ArrayList;
24 import java.util.List;
25 import org.onap.policy.utils.PeCryptoUtils;
26 import org.onap.portalapp.login.LoginStrategyImpl;
27 import org.onap.portalapp.scheduler.RegistryAdapter;
28 import org.onap.portalsdk.core.auth.LoginStrategy;
29 import org.onap.portalsdk.core.conf.AppConfig;
30 import org.onap.portalsdk.core.conf.Configurable;
31 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
32 import org.onap.portalsdk.core.objectcache.AbstractCacheManager;
33 import org.onap.portalsdk.core.service.DataAccessService;
34 import org.onap.portalsdk.core.util.CacheManager;
35 import org.onap.portalsdk.core.util.SystemProperties;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.context.annotation.Bean;
38 import org.springframework.context.annotation.ComponentScan;
39 import org.springframework.context.annotation.Configuration;
40 import org.springframework.context.annotation.Import;
41 import org.springframework.context.annotation.Profile;
42 import org.springframework.context.annotation.PropertySource;
43 import org.springframework.scheduling.annotation.EnableAsync;
44 import org.springframework.scheduling.annotation.EnableScheduling;
45 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
46 import org.springframework.web.servlet.ViewResolver;
47 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
48 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
49 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
52 * ONAP Portal SDK sample application. Extends core AppConfig class to reuse interceptors, view resolvers and other
53 * features defined there.
57 @ComponentScan(basePackages = "org.onap")
58 @PropertySource(value = {"${container.classpath:}/WEB-INF/conf/app/test.properties"}, ignoreResourceNotFound = true)
62 public class ExternalAppConfig extends AppConfig implements Configurable {
64 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExternalAppConfig.class);
66 private RegistryAdapter schedulerRegistryAdapter;
69 @Import(SystemProperties.class)
70 static class InnerConfiguration {
74 * @see org.onap.portalsdk.core.conf.AppConfig#viewResolver()
77 public ViewResolver viewResolver() {
78 return super.viewResolver();
82 * @see org.onap.portalsdk.core.conf.AppConfig#addResourceHandlers(ResourceHandlerRegistry)
87 public void addResourceHandlers(ResourceHandlerRegistry registry) {
88 super.addResourceHandlers(registry);
92 * @see org.onap.portalsdk.core.conf.AppConfig#dataAccessService()
95 public DataAccessService dataAccessService() {
96 // Echo the JDBC URL to assist developers when starting the app.
97 System.out.println("ExternalAppConfig: " + SystemProperties.DB_CONNECTIONURL + " is "
98 + SystemProperties.getProperty(SystemProperties.DB_CONNECTIONURL));
99 System.setProperty(SystemProperties.DB_PASSWORD,
100 PeCryptoUtils.decrypt(SystemProperties.getProperty(SystemProperties.DB_PASSWORD)));
101 return super.dataAccessService();
105 * Creates a new list with a single entry that is the external app definitions.xml path.
107 * @return List of String, size 1
110 public List<String> addTileDefinitions() {
111 List<String> definitions = new ArrayList<>();
112 definitions.add("/WEB-INF/defs/definitions.xml");
117 * Adds request interceptors to the specified registry by calling
118 * {@link AppConfig#addInterceptors(InterceptorRegistry)}, but excludes certain paths from the session timeout
122 public void addInterceptors(InterceptorRegistry registry) {
123 super.setExcludeUrlPathsForSessionTimeout("/login_external", "*/login_external.htm", "login", "/login.htm",
124 "/api*", "/single_signon.htm", "/single_signon");
125 super.addInterceptors(registry);
129 * Creates and returns a new instance of a {@link CacheManager} class.
131 * @return New instance of {@link CacheManager}
134 public AbstractCacheManager cacheManager() {
135 return new CacheManager();
139 * Creates and returns a new instance of a {@link SchedulerFactoryBean} and populates it with triggers.
141 * @return New instance of {@link SchedulerFactoryBean}
144 // @Bean // ANNOTATION COMMENTED OUT
145 // APPLICATIONS REQUIRING QUARTZ SHOULD RESTORE ANNOTATION
146 public SchedulerFactoryBean schedulerFactoryBean() {
147 SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
148 scheduler.setTriggers(schedulerRegistryAdapter.getTriggers());
149 scheduler.setConfigLocation(appApplicationContext.getResource("WEB-INF/conf/quartz.properties"));
151 scheduler.setDataSource(dataSource());
152 } catch (Exception e) {
153 logger.error("Exception occured While Setting DataSource for schedulerfactorybean" + e);
160 * Sets the scheduler registry adapter.
162 * @param schedulerRegistryAdapter
165 public void setSchedulerRegistryAdapter(final RegistryAdapter schedulerRegistryAdapter) {
166 this.schedulerRegistryAdapter = schedulerRegistryAdapter;
170 public LoginStrategy loginStrategy() {
171 return new LoginStrategyImpl();