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.openecomp.portalapp.conf;
22 import java.util.ArrayList;
23 import java.util.List;
25 import org.openecomp.portalapp.login.LoginStrategyImpl;
26 import org.openecomp.portalapp.scheduler.RegistryAdapter;
27 import org.openecomp.portalsdk.core.auth.LoginStrategy;
28 import org.openecomp.portalsdk.core.conf.AppConfig;
29 import org.openecomp.portalsdk.core.conf.Configurable;
30 import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager;
31 import org.openecomp.portalsdk.core.service.DataAccessService;
32 import org.openecomp.portalsdk.core.util.CacheManager;
33 import org.openecomp.portalsdk.core.util.SystemProperties;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.context.annotation.Bean;
36 import org.springframework.context.annotation.ComponentScan;
37 import org.springframework.context.annotation.Configuration;
38 import org.springframework.context.annotation.Import;
39 import org.springframework.context.annotation.Profile;
40 import org.springframework.context.annotation.PropertySource;
41 import org.springframework.scheduling.annotation.EnableAsync;
42 import org.springframework.scheduling.annotation.EnableScheduling;
43 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
44 import org.springframework.web.servlet.ViewResolver;
45 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
46 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
47 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
50 * ECOMP Portal SDK sample application. ECOMP Portal SDK core AppConfig class to
51 * reuse interceptors, view resolvers and other features defined there.
55 @ComponentScan(basePackages = "org.openecomp")
56 @PropertySource(value = { "${container.classpath:}/WEB-INF/conf/app/test.properties" }, ignoreResourceNotFound = true)
60 public class ExternalAppConfig extends AppConfig implements Configurable {
62 private RegistryAdapter schedulerRegistryAdapter;
65 @Import(SystemProperties.class)
66 static class InnerConfiguration {
70 * @see org.openecomp.portalsdk.core.conf.AppConfig#viewResolver()
72 public ViewResolver viewResolver() {
73 return super.viewResolver();
77 * @see org.openecomp.portalsdk.core.conf.AppConfig#addResourceHandlers(ResourceHandlerRegistry)
81 public void addResourceHandlers(ResourceHandlerRegistry registry) {
82 super.addResourceHandlers(registry);
86 * @see org.openecomp.portalsdk.core.conf.AppConfig#dataAccessService()
88 public DataAccessService dataAccessService() {
89 // Echo the JDBC URL to assist developers when starting the app.
90 System.out.println("ExternalAppConfig: " + SystemProperties.DB_CONNECTIONURL + " is "
91 + SystemProperties.getProperty(SystemProperties.DB_CONNECTIONURL));
92 return super.dataAccessService();
96 * Creates a new list with a single entry that is the external app
97 * definitions.xml path.
99 * @return List of String, size 1
101 public List<String> addTileDefinitions() {
102 List<String> definitions = new ArrayList<String>();
103 definitions.add("/WEB-INF/defs/definitions.xml");
108 * Adds request interceptors to the specified registry by calling
109 * {@link AppConfig#addInterceptors(InterceptorRegistry)}, but excludes
110 * certain paths from the session timeout interceptor.
113 public void addInterceptors(InterceptorRegistry registry) {
114 super.setExcludeUrlPathsForSessionTimeout("/login_external", "*/login_external.htm", "login", "/login.htm",
115 "/api*", "/single_signon.htm", "/single_signon");
116 super.addInterceptors(registry);
120 * Creates and returns a new instance of a {@link CacheManager} class.
122 * @return New instance of {@link CacheManager}
125 public AbstractCacheManager cacheManager() {
126 return new CacheManager();
130 * Creates and returns a new instance of a {@link SchedulerFactoryBean} and
131 * populates it with triggers.
133 * @return New instance of {@link SchedulerFactoryBean}
136 // @Bean // ANNOTATION COMMENTED OUT
137 // APPLICATIONS REQUIRING QUARTZ SHOULD RESTORE ANNOTATION
138 public SchedulerFactoryBean schedulerFactoryBean() throws Exception {
139 SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
140 scheduler.setTriggers(schedulerRegistryAdapter.getTriggers());
141 scheduler.setConfigLocation(appApplicationContext.getResource("WEB-INF/conf/quartz.properties"));
142 scheduler.setDataSource(dataSource());
147 * Sets the scheduler registry adapter.
149 * @param schedulerRegistryAdapter
152 public void setSchedulerRegistryAdapter(final RegistryAdapter schedulerRegistryAdapter) {
153 this.schedulerRegistryAdapter = schedulerRegistryAdapter;
157 public LoginStrategy loginStrategy() {
159 return new LoginStrategyImpl();