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
21 import org.kuali.common.util.Assert;
22 import org.kuali.common.util.LocationUtils;
23 import org.kuali.common.util.nullify.NullUtils;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 public abstract class AbstractCopyLocationsExecutable implements Executable {
28
29 private static final Logger logger = LoggerFactory.getLogger(AbstractCopyLocationsExecutable.class);
30
31 String locationListing;
32 File directory;
33
34 protected abstract List<File> getFiles(List<String> locations);
35
36 @Override
37 public void execute() {
38 if (NullUtils.isNullOrNone(locationListing)) {
39 logger.info("Skipping execution. Location listing [{}]", locationListing);
40 return;
41 }
42 Assert.notNull(locationListing);
43 Assert.notNull(directory);
44 Assert.isTrue(LocationUtils.exists(locationListing));
45 logger.info("Copying [{}] -> [{}]", locationListing, LocationUtils.getCanonicalPath(directory));
46 List<String> locations = LocationUtils.getLocations(locationListing);
47 List<File> files = getFiles(locations);
48 LocationUtils.copyLocationsToFiles(locations, files);
49 logger.info("Copied {} files", locations.size());
50 }
51
52 public String getLocationListing() {
53 return locationListing;
54 }
55
56 public void setLocationListing(String locationListing) {
57 this.locationListing = locationListing;
58 }
59
60 public File getDirectory() {
61 return directory;
62 }
63
64 public void setDirectory(File directory) {
65 this.directory = directory;
66 }
67 }