1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package openr66.context.task;
22
23 import goldengate.common.logging.GgInternalLogger;
24 import goldengate.common.logging.GgInternalLoggerFactory;
25
26 import java.io.File;
27
28 import openr66.context.R66Session;
29 import openr66.protocol.exception.OpenR66ProtocolSystemException;
30 import openr66.protocol.utils.FileUtils;
31
32
33
34
35
36
37
38 public class CopyRenameTask extends AbstractTask {
39
40
41
42 private static final GgInternalLogger logger = GgInternalLoggerFactory
43 .getLogger(CopyRenameTask.class);
44
45
46
47
48
49
50
51 public CopyRenameTask(String argRule, int delay, String argTransfer,
52 R66Session session) {
53 super(TaskType.COPYRENAME, delay, argRule, argTransfer, session);
54 }
55
56
57
58
59
60
61 @Override
62 public void run() {
63 String finalname = argRule;
64 finalname = getReplacedValue(finalname, argTransfer.split(" "));
65 logger.info("Copy and Rename to " + finalname + " with " + argRule +
66 ":" + argTransfer + " and {}", session);
67 File from = session.getFile().getTrueFile();
68 File to = new File(finalname);
69 try {
70 FileUtils.copy(from, to, false, false);
71 } catch (OpenR66ProtocolSystemException e1) {
72 logger.error("Copy and Rename to " + finalname + " with " +
73 argRule + ":" + argTransfer + " and " + session, e1);
74 futureCompletion.setFailure(new OpenR66ProtocolSystemException(e1));
75 return;
76 }
77 futureCompletion.setSuccess();
78 }
79
80 }