001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.xml.spring; 017 018import java.util.List; 019import java.util.Properties; 020 021import com.google.common.collect.Lists; 022import org.kuali.common.jdbc.project.spring.JdbcPropertyLocationsConfig; 023import org.kuali.common.util.project.ProjectUtils; 024import org.kuali.common.util.properties.Location; 025import org.kuali.common.util.properties.PropertiesService; 026import org.kuali.common.util.properties.spring.DefaultPropertiesServiceConfig; 027import org.kuali.common.util.spring.service.PropertySourceConfig; 028import org.kuali.rice.core.api.config.property.Config; 029import org.kuali.rice.sql.spring.SourceSqlPropertyLocationsConfig; 030import org.kuali.rice.xml.ingest.RiceConfigUtils; 031import org.springframework.beans.factory.annotation.Autowired; 032import org.springframework.context.annotation.Bean; 033import org.springframework.context.annotation.Configuration; 034import org.springframework.context.annotation.Import; 035import org.springframework.core.env.PropertiesPropertySource; 036import org.springframework.core.env.PropertySource; 037 038/** 039 * Holds the property source for all of the different properties needed for the workflow XML ingestion process. 040 * 041 * @author Kuali Rice Team (rice.collab@kuali.org) 042 */ 043@Configuration 044@Import({ JdbcPropertyLocationsConfig.class, DefaultPropertiesServiceConfig.class, SourceSqlPropertyLocationsConfig.class, IngestXmlPropertyLocationsConfig.class }) 045public class IngestXmlPSC implements PropertySourceConfig { 046 047 /** 048 * The general JDBC property locations. 049 */ 050 @Autowired 051 JdbcPropertyLocationsConfig jdbcConfig; 052 053 /** 054 * The Rice property locations for the database reset process. 055 */ 056 @Autowired 057 SourceSqlPropertyLocationsConfig sourceSqlConfig; 058 059 /** 060 * The Rice property locations for the workflow XML ingestion process. 061 */ 062 @Autowired 063 IngestXmlPropertyLocationsConfig ingestXmlConfig; 064 065 /** 066 * The property locator. 067 */ 068 @Autowired 069 PropertiesService service; 070 071 /** 072 * {@inheritDoc} 073 * 074 * <p> 075 * Here we combine all properties, making sure that the Rice project properties go in last. 076 * </p> 077 */ 078 @Override 079 @Bean 080 public PropertySource<?> propertySource() { 081 List<Location> locations = Lists.newArrayList(); 082 083 locations.addAll(jdbcConfig.jdbcPropertyLocations()); 084 locations.addAll(sourceSqlConfig.riceSourceSqlPropertyLocations()); 085 locations.addAll(ingestXmlConfig.riceIngestXmlPropertyLocations()); 086 087 Properties properties = service.getProperties(locations); 088 089 String location = ProjectUtils.getPath(RiceXmlProperties.APP.getResource()); 090 Config riceConfig = RiceConfigUtils.parseAndInit(location); 091 RiceConfigUtils.putProperties(riceConfig, properties); 092 093 return new PropertiesPropertySource("properties", riceConfig.getProperties()); 094 } 095 096}