View Javadoc

1   package org.kuali.common.impex.spring;
2   
3   import java.io.File;
4   import java.io.IOException;
5   import java.util.Arrays;
6   import java.util.List;
7   
8   import org.kuali.common.util.CollectionUtils;
9   import org.kuali.common.util.MetaInfUtils;
10  import org.kuali.common.util.metainf.MetaInfContext;
11  import org.kuali.common.util.spring.SpringUtils;
12  import org.springframework.beans.factory.annotation.Autowired;
13  import org.springframework.context.annotation.Bean;
14  import org.springframework.context.annotation.Configuration;
15  import org.springframework.core.env.Environment;
16  
17  @Configuration
18  @Deprecated
19  public class MetaInfMpxConfig {
20  
21  	@Autowired
22  	Environment env;
23  
24  	@Bean
25  	public Object scanAndCreateFiles() {
26  		// Extract the CSV include patterns and convert to a list
27  		String csv = SpringUtils.getProperty(env, "impex.metainf.includes", "**/*.mpx");
28  		List<String> includes = CollectionUtils.getTrimmedListFromCSV(csv);
29  
30  		// This is the base directory to scan
31  		File baseDir = new File(SpringUtils.getProperty(env, "project.build.outputDirectory"));
32  
33  		// Output file contains one line of text for each file that gets located
34  		// Each line is an entry similar to this "classpath:MYCONTENT.mpx"
35  		File outputFile = new File(SpringUtils.getProperty(env, "impex.metainf.outputFile"));
36  
37  		// Setup the context
38  		MetaInfContext context = new MetaInfContext();
39  		context.setBaseDir(baseDir);
40  		context.setOutputFile(outputFile);
41  		context.setIncludes(includes);
42  
43  		try {
44  			// Invoke MetaInfUtils to create the resource listings
45  			MetaInfUtils.scanAndCreateFiles(Arrays.asList(context));
46  		} catch (IOException e) {
47  			throw new IllegalStateException(e);
48  		}
49  		return null;
50  	}
51  }