1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.sys;
17
18
19 import java.io.IOException;
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import org.kuali.rice.krad.bo.ModuleConfiguration;
24 import org.kuali.rice.krad.datadictionary.DataDictionaryException;
25 import org.springframework.core.io.ClassPathResource;
26 import org.springframework.core.io.FileSystemResource;
27 import org.springframework.core.io.Resource;
28 import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
29
30 public class KpmeModuleConfiguration extends ModuleConfiguration {
31 @Override
32 public void setDataDictionaryPackages(List<String> dataDictionaryPackages) {
33 this.trimList(dataDictionaryPackages);
34
35
36 List<String> ddFiles = new ArrayList<String>();
37 for (String ddPackage : dataDictionaryPackages) {
38 if (ddPackage.contains("*")) {
39 try {
40 PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
41 Resource[] resources = resolver.getResources(ddPackage);
42 for (Resource resource : resources) {
43 String prefix = "classpath:";
44 if (resource instanceof FileSystemResource) {
45 ddFiles.add("file:" + ((FileSystemResource)resource).getPath());
46 } else if (resource instanceof ClassPathResource) {
47 ddFiles.add("classpath:" + ((ClassPathResource)resource).getPath());
48 } else {
49 throw new DataDictionaryException("DD Resource " + resource.getFile().getPath() + " not found");
50 }
51 }
52 } catch (IOException e) {
53 throw new DataDictionaryException("DD Resource " + ddPackage + " not found");
54 }
55 } else {
56 ddFiles.add(ddPackage);
57 }
58 }
59 this.dataDictionaryPackages = ddFiles;
60 }
61 }