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.util.Arrays;
19 import java.util.List;
20
21 import org.kuali.common.util.Assert;
22 import org.kuali.common.util.FileSystemUtils;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 public class CopyFilesExecutable implements Executable {
27
28 private static final Logger logger = LoggerFactory.getLogger(CopyFilesExecutable.class);
29
30 boolean skip;
31 List<CopyFileRequest> requests;
32
33
34 List<CopyFileResult> results;
35
36 public CopyFilesExecutable() {
37 this(null, false);
38 }
39
40 public CopyFilesExecutable(CopyFileRequest request) {
41 this(Arrays.asList(request), false);
42 }
43
44 public CopyFilesExecutable(List<CopyFileRequest> requests) {
45 this(requests, false);
46 }
47
48 public CopyFilesExecutable(List<CopyFileRequest> requests, boolean skip) {
49 super();
50 this.requests = requests;
51 this.skip = skip;
52 }
53
54 @Override
55 public void execute() {
56
57
58 if (skip) {
59 return;
60 }
61
62
63 Assert.notNull(requests, "requests is null");
64
65
66 logger.info("Copying {} files", requests.size());
67
68
69 List<CopyFileResult> results = FileSystemUtils.copyFiles(requests);
70
71
72 this.results = results;
73 }
74
75
76
77
78 public List<CopyFileResult> getResults() {
79 return results;
80 }
81
82 public List<CopyFileRequest> getRequests() {
83 return requests;
84 }
85
86 public void setRequests(List<CopyFileRequest> requests) {
87 this.requests = requests;
88 }
89
90 public boolean isSkip() {
91 return skip;
92 }
93
94 public void setSkip(boolean skip) {
95 this.skip = skip;
96 }
97
98 }