001 /**
002 * Copyright 2010-2013 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 */
016 package org.kuali.common.util.spring;
017
018 import java.util.ArrayList;
019 import java.util.Arrays;
020 import java.util.List;
021
022 import org.kuali.common.util.Project;
023 import org.kuali.common.util.ProjectContext;
024 import org.kuali.common.util.ProjectUtils;
025 import org.kuali.common.util.property.ProjectProperties;
026 import org.kuali.common.util.property.PropertiesContext;
027
028 public class ConfigUtils {
029
030 public static List<ProjectProperties> getProjectProperties(List<ProjectContext> contexts) {
031 List<ProjectProperties> list = new ArrayList<ProjectProperties>();
032 for (ProjectContext context : contexts) {
033 Project project = ProjectUtils.loadProject(context);
034 ProjectProperties pp = getProjectProperties(project, context.getPropertyLocations());
035 list.add(pp);
036 }
037 return list;
038 }
039
040 public static List<ProjectProperties> getProjectProperties(ProjectContext... contexts) {
041 return getProjectProperties(Arrays.asList(contexts));
042 }
043
044 public static ProjectProperties getProjectProperties(ProjectContext context) {
045 Project project = ProjectUtils.loadProject(context);
046 return getProjectProperties(project, context.getPropertyLocations());
047 }
048
049 public static ProjectProperties getProjectProperties(Project project, List<String> locations) {
050 PropertiesContext pc = new PropertiesContext();
051 pc.setEncoding(project.getEncoding());
052 pc.setLocations(locations);
053 return new ProjectProperties(project, pc);
054 }
055 }