1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.execute;
17
18 import java.io.File;
19 import java.util.List;
20 import java.util.Properties;
21
22 import org.kuali.common.util.CollectionUtils;
23 import org.kuali.common.util.ComparisonResults;
24 import org.kuali.common.util.LocationUtils;
25 import org.kuali.common.util.PropertyUtils;
26 import org.kuali.common.util.SimpleScanner;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29 import org.springframework.util.Assert;
30
31
32
33
34
35
36
37
38 @Deprecated
39 public class FileListComparisonExecutable implements Executable {
40
41 private static final Logger logger = LoggerFactory.getLogger(FileListComparisonExecutable.class);
42
43 private String newFilesBaseDir;
44 private String filePattern;
45 private String originalFilesBaseDir;
46 private List<String> propertyNames;
47 private Properties mavenProperties;
48
49 @Override
50 public void execute() {
51 Assert.notNull(mavenProperties);
52 Assert.notNull(propertyNames);
53 Assert.notNull(newFilesBaseDir);
54 Assert.notNull(originalFilesBaseDir);
55 Assert.notNull(filePattern);
56
57 logger.info("Starting File List Comparison");
58 logger.info("Original files dir: " + originalFilesBaseDir);
59 logger.info("New files dir: " + LocationUtils.getCanonicalPath(new File(newFilesBaseDir)));
60 logger.info("File pattern: " + filePattern);
61 logger.info("Property names: " + propertyNames);
62
63 List<String> filePatterns = CollectionUtils.getTrimmedListFromCSV(filePattern);
64 String[] includesArray = filePatterns.toArray(new String[filePatterns.size()]);
65
66 SimpleScanner scanner = new SimpleScanner();
67 scanner.setBasedir(newFilesBaseDir);
68 scanner.setIncludes(includesArray);
69
70 List<String> newLocations = LocationUtils.getAbsolutePaths(scanner.getFiles());
71 List<String> newFileNames = LocationUtils.getFilenames(newLocations);
72
73 scanner = new SimpleScanner();
74 scanner.setBasedir(originalFilesBaseDir);
75 scanner.setIncludes(includesArray);
76
77 List<String> originalLocations = LocationUtils.getAbsolutePaths(scanner.getFiles());
78 List<String> originalFileNames = LocationUtils.getFilenames(originalLocations);
79
80 ComparisonResults comparison = LocationUtils.getLocationListComparison(newFileNames, originalFileNames);
81
82 logger.info("Added {} files.", comparison.getAdded().size());
83 logger.info("Updated {} existing files.", comparison.getSame().size());
84 logger.info("Deleted {} files.", comparison.getDeleted().size());
85
86 PropertyUtils.addListComparisonProperties(mavenProperties, comparison, propertyNames);
87 }
88
89 public String getFilePattern() {
90 return filePattern;
91 }
92
93 public void setFilePattern(String filePattern) {
94 this.filePattern = filePattern;
95 }
96
97 public Properties getMavenProperties() {
98 return mavenProperties;
99 }
100
101 public void setMavenProperties(Properties mavenProperties) {
102 this.mavenProperties = mavenProperties;
103 }
104
105 public String getNewFilesBaseDir() {
106 return newFilesBaseDir;
107 }
108
109 public void setNewFilesBaseDir(String newFilesBaseDir) {
110 this.newFilesBaseDir = newFilesBaseDir;
111 }
112
113 public String getOriginalFilesBaseDir() {
114 return originalFilesBaseDir;
115 }
116
117 public void setOriginalFilesBaseDir(String originalFilesBaseDir) {
118 this.originalFilesBaseDir = originalFilesBaseDir;
119 }
120
121 public List<String> getPropertyNames() {
122 return propertyNames;
123 }
124
125 public void setPropertyNames(List<String> propertyNames) {
126 this.propertyNames = propertyNames;
127 }
128 }