summaryrefslogtreecommitdiffstats
path: root/newton/pom.xml
AgeCommit message (Collapse)AuthorFilesLines
2018-11-27bump version 1.2.3Xiaohua Zhang1-1/+1
Change-Id: Ic63d11ec0ac588dc954765dbc4c0d19be4277feb Issue-ID: MULTICLOUD-419 Signed-off-by: Xiaohua Zhang <xiaohua.zhang@windriver.com>
2018-11-13Bump version to 1.2.2Bin Yang1-1/+1
Change-Id: Ib70c2bff78f5be8d63c2bb2e612c84cf3d97fb27 Issue-ID: MULTICLOUD-402 Signed-off-by: Bin Yang <bin.yang@windriver.com>
2018-10-16Update multicloud openstack release versionHuang Haibin1-1/+1
Change-Id: I7c1f58971008ae65dd06f48e7dc3332cb1ea3e2d Issue-ID: MULTICLOUD-379 Signed-off-by: Huang Haibin <haibin.huang@intel.com>
2018-09-06Clean Sonar Project nameGildas Lanilis1-1/+1
Name to be consistant with repo name. Change-Id: Ib93070d82322eb3ae2d019a7f0dacabeeba11129 Issue-ID: CIMAN-202 Signed-off-by: Gildas Lanilis <gildas.lanilis@huawei.com>
2018-08-27Bump oparent version to 1.2.0Gary Wu1-5/+2
This change was submitted by script and may include additional whitespace or formatting changes. Change-Id: I4de0c691526147da1a898ce4e46be9f716d87e77 Issue-ID: INT-619 Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
2018-06-12Bump version after Beijing releaseYun Huang1-1/+1
Bump version from 1.1.2 to 1.2.0 Change-Id: I72d8f5ba7fef9546120222f1d76133cc1fbf8341 Issue-ID: MULTICLOUD-245 Signed-off-by: Yun Huang <yun.huang@windriver.com>
2018-04-25Bump and align versionsYun Huang1-1/+1
Change-Id: I8e92f27271b01c9d5e0f3897b9e7f60aa4b8db75 Issue-ID: MULTICLOUD-215 Signed-off-by: Yun Huang <yun.huang@windriver.com>
2018-03-18Correct sonar script pathnameYun Huang1-2/+2
Change-Id: Idc527e0bea04556f78789042faf2d0fff7ccacf4 Issue-ID: MULTICLOUD-171 Signed-off-by: Yun Huang <yun.huang@windriver.com>
2018-03-16Upgrade to latest oparentBin Yang1-1/+1
Update pom.xml file to latest version release of oparent, 1.1.0 Change-Id: I4aeb8eee4419446486f251655015ca9c9c992a50 Issue-ID: INT-443 Signed-off-by: Gildas Lanilis <gildas.lanilis@huawei.com> Signed-off-by: Bin Yang <bin.yang@windriver.com>
2018-03-15modify log directoryHuang Haibin1-35/+35
Change-Id: I119b9018b9f403fb9f6637abe048e99f0f00c0c1 Issue-ID: MULTICLOUD-138 Signed-off-by: Huang Haibin <haibin.huang@intel.com>
2018-03-15Delete repeat file with share directoryHuang Haibin1-8/+0
Change-Id: I93ecf179670216cb0b82803048daf22d0cd3b915 Issue-ID: MULTICLOUD-138 Signed-off-by: Huang Haibin <haibin.huang@intel.com>
2018-03-14Fix sonar coverage issue for newtonYun Huang1-3/+62
Change-Id: I14d4b9063528e65e90efa2ea38e155d4b6c2761d Issue-ID: MULTICLOUD-171 Signed-off-by: Yun Huang <yun.huang@windriver.com>
2018-03-10newton use share libraryHuang Haibin1-47/+0
Change-Id: I0ed8ced042862edf8afa87fec3b457d019e811b4 Issue-ID: MULTICLOUD-138 Signed-off-by: Huang Haibin <haibin.huang@intel.com>
2018-03-06Add sonar coverage for MultiCloud OpenStackYun Huang1-0/+7
Change-Id: I6526b56a06cd430bb1b95e7175d2a6d8f48ebc0c Issue-ID: MULTICLOUD-171 Signed-off-by: Yun Huang <yun.huang@windriver.com>
2018-03-06Update Newton license headerYun Huang1-3/+6
Change-Id: I2ee874ab6a4f13e7a5b2fe32f80ba0225d086a9f Issue-ID: MULTICLOUD-140 Signed-off-by: Yun Huang <yun.huang@windriver.com>
2018-01-09Fix version dependenciesVictor Morales1-1/+1
The version number used for newton needs to be higher to allow other to refer it. Change-Id: Id88c3450f62bb21b8eacc489ef3be58f8ec7e192 Signed-off-by: Victor Morales <victor.morales@intel.com> Issue-ID: MULTICLOUD-83
2017-12-05Bump minor version,step 1Bin Yang1-1/+1
Bump minor version in preparation for Amsterdam branching. Change-Id: I42c8fe8ffa2c8c3651454567e6045a0fc2aef4a5 Issue-ID: CIMAN-120 Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org> Signed-off-by: Bin Yang <bin.yang@windriver.com>
2017-11-16Update Dependency on oparentv1.0.01.0.0-ONAP1.0.0-AmsterdamBin Yang1-1/+1
Update POM setting of OpenStack plugins Change-Id: I92d67244ff24cef00f72278652e33794d73ad53e Issue-Id: MULTICLOUD-128 Signed-off-by: Bin Yang <bin.yang@windriver.com>
2017-10-11Add staging docker images for OpenStack pluginsBin Yang1-0/+6
Add staging docker images and enable logger of submodules Change-Id: Ib64f30ab50002dca67c6835866ffc46fc83d7934 Issue-Id: MULTICLOUD-110 Signed-off-by: Bin Yang <bin.yang@windriver.com>
2017-09-08Add docker build fileBin Yang1-1/+51
add docker build file to generate container image Change-Id: I08e289dea8caf01b9690d80c2c21355d0f121a6b Issue-Id: MULTICLOUD-58 Signed-off-by: Bin Yang <bin.yang@windriver.com>
2017-08-30Update newton pom settingBin Yang1-3/+3
change the parent pom to oparent Change-Id: I9cec5dfa5f23c109691226a31421692e3515f188 Issue-Id: MULTICLOUD-58 Signed-off-by: Bin Yang <bin.yang@windriver.com>
2017-08-30Fix pom setting for newtonBin Yang1-0/+1
fix the parent setting of newton subproject which results in failure of multicloud-openstack-master-merge-java Change-Id: Iee70d4d642186d633ad8fcdf12529d0e79e3eaa4 Issue-Id: MULTICLOUD-58 Signed-off-by: Bin Yang <bin.yang@windriver.com>
2017-08-29Add OpenStack proxy for newtonBin Yang1-8/+8
refactor seed code for newton add proxy for identiy,service, add registration, extension management Issue-Id: MULTICLOUD-58 Change-Id: I6a7a21427af4c88b7f060470c1176009c13fc19e Signed-off-by: Bin Yang <bin.yang@windriver.com>
2017-02-22Setup micro-service of newton driverBin Yang1-0/+49
Change-Id: I86dd5d3032eb70d0c1c1c23d179de2a0a2a1fdeb Issue-Id: MULTIVIM-18 Signed-off-by: Bin Yang <bin.yang@windriver.com>
eral.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*-
 * ================================================================================
 * ECOMP Portal SDK
 * ================================================================================
 * Copyright (C) 2017 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.openecomp.portalsdk.core.conf;

import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

import org.openecomp.portalsdk.core.interceptor.ResourceInterceptor;
import org.openecomp.portalsdk.core.interceptor.SessionTimeoutInterceptor;
import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum;
import org.openecomp.portalsdk.core.logging.format.AppMessagesEnum;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.menu.MenuBuilder;
import org.openecomp.portalsdk.core.onboarding.util.CipherUtil;
import org.openecomp.portalsdk.core.service.DataAccessService;
import org.openecomp.portalsdk.core.service.DataAccessServiceImpl;
import org.openecomp.portalsdk.core.service.LocalAccessCondition;
import org.openecomp.portalsdk.core.service.RestApiRequestBuilder;
import org.openecomp.portalsdk.core.util.SystemProperties;
import org.openecomp.portalsdk.core.web.support.AppUtils;
import org.openecomp.portalsdk.core.web.support.UserUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import org.springframework.web.servlet.view.UrlBasedViewResolver;
import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
import org.springframework.web.servlet.view.tiles3.TilesView;

import com.mchange.v2.c3p0.ComboPooledDataSource;

/**
 * Configures Spring features in the ECOMP Portal SDK including request
 * interceptors and view resolvers. Application should subclass and override
 * methods as needed.
 */
public class AppConfig extends WebMvcConfigurerAdapter implements Configurable, ApplicationContextAware {

	EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppConfig.class);

	private final List<String> tileDefinitions = new ArrayList<String>();
	protected ApplicationContext appApplicationContext = null;

	public AppConfig() {
		// loads all default fields and marks logging
		// has been started for each log file type.
		initGlobalLocalContext();
	}

	/**
	 * Creates and returns a new instance of a secondary (order=2)
	 * {@link ViewResolver} that finds files by adding prefix "/WEB-INF/jsp/"
	 * and suffix ".jsp" to the base view name.
	 * 
	 * @return New instance of {@link ViewResolver}.
	 */
	@Bean
	public ViewResolver viewResolver() {
		InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
		viewResolver.setViewClass(JstlView.class);
		viewResolver.setPrefix("/WEB-INF/jsp/");
		viewResolver.setSuffix(".jsp");
		viewResolver.setOrder(2);
		return viewResolver;
	}

	/**
	 * Loads all the default logging fields into the global MDC context and
	 * marks each log file type that logging has been started.
	 */
	private void initGlobalLocalContext() {
		logger.init();
	}

	/*
	 * Any requests from the url pattern /static/**, Spring will look for the
	 * resources from the /static/ Same as <mvc:resources mapping="/static/**"
	 * location="/static/"/> in xml
	 */
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		// registry.addResourceHandler("/static/**").addResourceLocations("/static/");
		registry.addResourceHandler("/**").addResourceLocations("/");
	}

	/**
	 * Creates and returns a new instance of a {@link DataAccessService} class.
	 * 
	 * @return New instance of {@link DataAccessService}.
	 */
	@Bean
	public DataAccessService dataAccessService() {
		return new DataAccessServiceImpl();
	}

	/**
	 * Creates and returns a new instance of a {@link SystemProperties} class.
	 * 
	 * @return New instance of {@link SystemProperties}.
	 */
	@Bean
	public SystemProperties systemProperties() {
		return new SystemProperties();
	}

	/**
	 * Creates and returns a new instance of a {@link MenuBuilder} class.
	 * 
	 * @return New instance of {@link MenuBuilder}.
	 */
	@Bean
	public MenuBuilder menuBuilder() {
		return new MenuBuilder();
	}
	
	/**
	 * Creates and returns a new instance of a {@link UserUtils} class.
	 * 
	 * @return New instance of {@link UserUtils}.
	 */
	@Bean
	public UserUtils userUtil()
	{
		return new UserUtils();
	}

	/**
	 * Creates and returns a new instance of an {@link AppUtils} class.
	 * 
	 * @return New instance of {@link AppUtils}.
	 */
	@Bean
	public AppUtils appUtils() {
		return new AppUtils();
	}

	/**
	 * Creates and returns a new instance of a {@link TilesConfigurer} class.
	 * 
	 * @return New instance of {@link TilesConfigurer}.
	 */
	@Bean
	public TilesConfigurer tilesConfigurer() {
		TilesConfigurer tilesConfigurer = new TilesConfigurer();
		tilesConfigurer.setDefinitions(tileDefinitions());
		tilesConfigurer.setCheckRefresh(true);
		return tilesConfigurer;
	}

	/**
	 * 
	 * Creates the Application Data Source.
	 * 
	 * @return DataSource Object
	 * @throws Exception
	 *             on failure to create data source object
	 */
	@Bean
	public DataSource dataSource() throws Exception {

		systemProperties();

		ComboPooledDataSource dataSource = new ComboPooledDataSource();
		try {
			dataSource.setDriverClass(SystemProperties.getProperty(SystemProperties.DB_DRIVER));
			dataSource.setJdbcUrl(SystemProperties.getProperty(SystemProperties.DB_CONNECTIONURL));
			dataSource.setUser(SystemProperties.getProperty(SystemProperties.DB_USERNAME));
			String password = SystemProperties.getProperty(SystemProperties.DB_PASSWORD);
			if (SystemProperties.containsProperty(SystemProperties.DB_ENCRYPT_FLAG)) {
				String encryptFlag = SystemProperties.getProperty(SystemProperties.DB_ENCRYPT_FLAG);
				if (encryptFlag != null && encryptFlag.equalsIgnoreCase("true")) {
					password = CipherUtil.decrypt(password);
				}
			}
			dataSource.setPassword(password);
			dataSource
					.setMinPoolSize(Integer.parseInt(SystemProperties.getProperty(SystemProperties.DB_MIN_POOL_SIZE)));
			dataSource
					.setMaxPoolSize(Integer.parseInt(SystemProperties.getProperty(SystemProperties.DB_MAX_POOL_SIZE)));
			dataSource.setIdleConnectionTestPeriod(
					Integer.parseInt(SystemProperties.getProperty(SystemProperties.IDLE_CONNECTION_TEST_PERIOD)));
			dataSource.setTestConnectionOnCheckout(getConnectionOnCheckout());
			dataSource.setPreferredTestQuery(getPreferredTestQuery());
		} catch (Exception e) {
			logger.error(EELFLoggerDelegate.errorLogger,
					"Error initializing database, verify database settings in properties file: "
							+ UserUtils.getStackTrace(e),
					AlarmSeverityEnum.CRITICAL);
			logger.error(EELFLoggerDelegate.debugLogger,
					"Error initializing database, verify database settings in properties file: "
							+ UserUtils.getStackTrace(e),
					AlarmSeverityEnum.CRITICAL);
			// Raise an alarm that opening a connection to the database failed.
			logger.logEcompError(AppMessagesEnum.BeDaoSystemError);
			throw e;
		}
		return dataSource;
	}

	/**
	 * Gets the value of the property
	 * {@link SystemProperties#PREFERRED_TEST_QUERY}; defaults to "Select 1" if
	 * the property is not defined.
	 * 
	 * @return String value that is a SQL query
	 */
	private String getPreferredTestQuery() {
		// Use simple default
		String preferredTestQueryStr = "SELECT 1";
		if (SystemProperties.containsProperty(SystemProperties.PREFERRED_TEST_QUERY)) {
			preferredTestQueryStr = SystemProperties.getProperty(SystemProperties.PREFERRED_TEST_QUERY);
			logger.debug(EELFLoggerDelegate.debugLogger, "getPreferredTestQuery: property key {} value is {}",
					SystemProperties.PREFERRED_TEST_QUERY, preferredTestQueryStr);
		} else {
			logger.info(EELFLoggerDelegate.errorLogger,
					"getPreferredTestQuery: property key {} not found, using default value {}",
					SystemProperties.PREFERRED_TEST_QUERY, preferredTestQueryStr);
		}
		return preferredTestQueryStr;
	}

	/**
	 * Gets the value of the property
	 * {@link SystemProperties#TEST_CONNECTION_ON_CHECKOUT}; defaults to true if
	 * the property is not defined.
	 * 
	 * @return Boolean value
	 */
	private Boolean getConnectionOnCheckout() {
		// Default to true, always test connection
		boolean testConnectionOnCheckout = true;
		if (SystemProperties.containsProperty(SystemProperties.TEST_CONNECTION_ON_CHECKOUT)) {
			testConnectionOnCheckout = Boolean
					.valueOf(SystemProperties.getProperty(SystemProperties.TEST_CONNECTION_ON_CHECKOUT));
			logger.debug(EELFLoggerDelegate.debugLogger, "getConnectionOnCheckout: property key {} value is {}",
					SystemProperties.TEST_CONNECTION_ON_CHECKOUT, testConnectionOnCheckout);
		} else {
			logger.info(EELFLoggerDelegate.errorLogger,
					"getConnectionOnCheckout: property key {} not found, using default value {}",
					SystemProperties.TEST_CONNECTION_ON_CHECKOUT, testConnectionOnCheckout);
		}
		return testConnectionOnCheckout;
	}

	/*
	 * TODO: Check whether it is appropriate to extend the list of tile
	 * definitions at every invocation.
	 */
	protected String[] tileDefinitions() {
		tileDefinitions.add("/WEB-INF/fusion/defs/definitions.xml");
		tileDefinitions.addAll(addTileDefinitions());

		return tileDefinitions.toArray(new String[0]);
	}

	/**
	 * Creates and returns a new empty list. This method should be overridden by
	 * child classes.
	 * 
	 * @return An empty list.
	 */
	public List<String> addTileDefinitions() {
		return new ArrayList<String>();
	}

	/**
	 * Creates and returns a new instance of a primary (order=1)
	 * {@link UrlBasedViewResolver} that finds files using the contents of
	 * definitions.xml files.
	 * 
	 * @return New instance of {@link UrlBasedViewResolver}
	 */
	@Bean
	public UrlBasedViewResolver tileViewResolver() {
		UrlBasedViewResolver viewResolver = new UrlBasedViewResolver();
		viewResolver.setViewClass(TilesView.class);
		viewResolver.setOrder(1);
		return viewResolver;
	}

	/**
	 * Adds new instances of the following interceptors to the specified
	 * interceptor registry: {@link SessionTimeoutInterceptor},
	 * {@link ResourceInterceptor}
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new SessionTimeoutInterceptor())
				.excludePathPatterns(getExcludeUrlPathsForSessionTimeout());
		registry.addInterceptor(resourceInterceptor());
	}

	/**
	 * Creates and returns a new instance of a {@link ResourceInterceptor}.
	 * 
	 * @return New instance of {@link ResourceInterceptor}
	 */
	@Bean
	public ResourceInterceptor resourceInterceptor() {
		return new ResourceInterceptor();
	}

	private String[] excludeUrlPathsForSessionTimeout = {};

	/**
	 * Gets the array of Strings that are paths excluded for session timeout.
	 * 
	 * @return Array of String
	 */
	public String[] getExcludeUrlPathsForSessionTimeout() {
		return excludeUrlPathsForSessionTimeout;
	}

	/**
	 * Sets the array of Strings that are paths excluded for session timeout.
	 * 
	 * @param excludeUrlPathsForSessionTimeout
	 *            Paths to exclude
	 */
	public void setExcludeUrlPathsForSessionTimeout(final String... excludeUrlPathsForSessionTimeout) {
		this.excludeUrlPathsForSessionTimeout = excludeUrlPathsForSessionTimeout;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.context.ApplicationContextAware#setApplicationContext
	 * (org.springframework.context.ApplicationContext)
	 */
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		appApplicationContext = applicationContext;

	}

}