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.context.filesystem.R66Dir;
30 import openr66.context.task.exception.OpenR66RunnerException;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 public class ValidFilePathTask extends AbstractTask {
46
47
48
49 private static final GgInternalLogger logger = GgInternalLoggerFactory
50 .getLogger(ValidFilePathTask.class);
51
52
53
54
55
56
57
58 public ValidFilePathTask(String argRule, int delay, String argTransfer,
59 R66Session session) {
60 super(TaskType.VALIDFILEPATH, delay, argRule, argTransfer, session);
61 }
62
63
64
65
66
67
68 @Override
69 public void run() {
70 String finalname = argRule;
71 finalname = R66Dir.normalizePath(
72 getReplacedValue(finalname, argTransfer.split(" ")));
73 logger.info("Test Valid Path with " + finalname + " from {}", session);
74 File from = session.getFile().getTrueFile();
75 String curpath = R66Dir.normalizePath(from.getAbsolutePath());
76 String [] paths = finalname.split(" ");
77 for (String base: paths) {
78 if (curpath.startsWith(base)) {
79 if (delay > 0) {
80 logger.info("Validate File "+curpath+" from " + base + " and\n " +
81 session.toString());
82 }
83 futureCompletion.setSuccess();
84 return;
85 }
86 }
87 if (delay > 0) {
88 logger.error("Unvalidate File: "+curpath+"\n " +
89 session.toString());
90 }
91 futureCompletion.setFailure(new OpenR66RunnerException("File not Validated"));
92 }
93
94 }