2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
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 * ================================================================================
20 package org.onap.portalapp.conf;
22 import java.util.ArrayList;
23 import java.util.List;
25 import org.onap.portalapp.login.LoginStrategyImpl;
26 import org.onap.portalapp.scheduler.RegistryAdapter;
27 import org.onap.portalsdk.core.auth.LoginStrategy;
28 import org.onap.portalsdk.core.conf.AppConfig;
29 import org.onap.portalsdk.core.conf.Configurable;
30 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
31 import org.onap.portalsdk.core.objectcache.AbstractCacheManager;
32 import org.onap.portalsdk.core.service.DataAccessService;
33 import org.onap.portalsdk.core.util.CacheManager;
34 import org.onap.portalsdk.core.util.SystemProperties;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.context.annotation.Bean;
37 import org.springframework.context.annotation.ComponentScan;
38 import org.springframework.context.annotation.Configuration;
39 import org.springframework.context.annotation.Import;
40 import org.springframework.context.annotation.Profile;
41 import org.springframework.context.annotation.PropertySource;
42 import org.springframework.scheduling.annotation.EnableAsync;
43 import org.springframework.scheduling.annotation.EnableScheduling;
44 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
45 import org.springframework.web.servlet.ViewResolver;
46 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
47 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
48 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
51 * ONAP Portal SDK sample application. Extends core AppConfig class to
52 * reuse interceptors, view resolvers and other features defined there.
56 @ComponentScan(basePackages = "org.onap")
57 @PropertySource(value = { "${container.classpath:}/WEB-INF/conf/app/test.properties" }, ignoreResourceNotFound = true)
61 public class ExternalAppConfig extends AppConfig implements Configurable {
63 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExternalAppConfig.class);
65 private RegistryAdapter schedulerRegistryAdapter;
68 @Import(SystemProperties.class)
69 static class InnerConfiguration {
73 * @see org.onap.portalsdk.core.conf.AppConfig#viewResolver()
76 public ViewResolver viewResolver() {
77 return super.viewResolver();
81 * @see org.onap.portalsdk.core.conf.AppConfig#addResourceHandlers(ResourceHandlerRegistry)
86 public void addResourceHandlers(ResourceHandlerRegistry registry) {
87 super.addResourceHandlers(registry);
91 * @see org.onap.portalsdk.core.conf.AppConfig#dataAccessService()
94 public DataAccessService dataAccessService() {
95 // Echo the JDBC URL to assist developers when starting the app.
96 System.out.println("ExternalAppConfig: " + SystemProperties.DB_CONNECTIONURL + " is "
97 + SystemProperties.getProperty(SystemProperties.DB_CONNECTIONURL));
98 return super.dataAccessService();
102 * Creates a new list with a single entry that is the external app
103 * definitions.xml path.
105 * @return List of String, size 1
108 public List<String> addTileDefinitions() {
109 List<String> definitions = new ArrayList<>();
110 definitions.add("/WEB-INF/defs/definitions.xml");
115 * Adds request interceptors to the specified registry by calling
116 * {@link AppConfig#addInterceptors(InterceptorRegistry)}, but excludes
117 * certain paths from the session timeout interceptor.
120 public void addInterceptors(InterceptorRegistry registry) {
121 super.setExcludeUrlPathsForSessionTimeout("/login_external", "*/login_external.htm", "login", "/login.htm",
122 "/api*", "/single_signon.htm", "/single_signon");
123 super.addInterceptors(registry);
127 * Creates and returns a new instance of a {@link CacheManager} class.
129 * @return New instance of {@link CacheManager}
132 public AbstractCacheManager cacheManager() {
133 return new CacheManager();
137 * Creates and returns a new instance of a {@link SchedulerFactoryBean} and
138 * populates it with triggers.
140 * @return New instance of {@link SchedulerFactoryBean}
143 // @Bean // ANNOTATION COMMENTED OUT
144 // APPLICATIONS REQUIRING QUARTZ SHOULD RESTORE ANNOTATION
145 public SchedulerFactoryBean schedulerFactoryBean(){
146 SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
147 scheduler.setTriggers(schedulerRegistryAdapter.getTriggers());
148 scheduler.setConfigLocation(appApplicationContext.getResource("WEB-INF/conf/quartz.properties"));
150 scheduler.setDataSource(dataSource());
151 } catch (Exception e) {
152 logger.error("Exception occured While Setting DataSource for schedulerfactorybean"+e);
159 * Sets the scheduler registry adapter.
161 * @param schedulerRegistryAdapter
164 public void setSchedulerRegistryAdapter(final RegistryAdapter schedulerRegistryAdapter) {
165 this.schedulerRegistryAdapter = schedulerRegistryAdapter;
169 public LoginStrategy loginStrategy() {
170 return new LoginStrategyImpl();