1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package tools.gsf.facade.runtag;
18
19 import COM.FutureTense.Interfaces.ICS;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22 import tools.gsf.facade.FTValListFacade;
23
24 import java.util.Enumeration;
25
26
27
28
29
30 public abstract class AbstractTagRunner extends FTValListFacade implements TagRunner {
31
32 private static final Logger LOG = LoggerFactory.getLogger("tools.gsf.facade.runtag.AbstractTagRunner");
33
34 private final String tagName;
35
36
37
38
39 protected AbstractTagRunner(String tagName) {
40 this.tagName = tagName;
41 }
42
43
44
45
46
47
48
49
50
51 protected void bind(ICS ics) {
52
53 }
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 public String execute(ICS ics) {
71 bind(ics);
72 if (ics.GetErrno() != 0) {
73 ics.ClearErrno();
74 }
75 preExecute(ics);
76
77 if (LOG.isTraceEnabled()) {
78 StringBuffer sb = new StringBuffer("About to execute runTag for tag: " + tagName + ". ");
79 sb.append("\nInput param list:");
80 for (Object k : list.keySet()) {
81 String key = (String) k;
82 sb.append("\n\t").append(key).append("=")
83 .append(isPW(key) ? "<password suppressed>" : list.getValString(key));
84 }
85 sb.append("\nVariables:");
86 Enumeration<?> e = ics.GetVars();
87 while (e.hasMoreElements()) {
88 String key = (String) e.nextElement();
89 sb.append("\n\t").append(key).append("=").append(isPW(key) ? "<password suppressed>" : ics.GetVar(key));
90 }
91 sb.append("\nSession Variables:");
92 e = ics.GetSSVars();
93 while (e.hasMoreElements()) {
94 String key = (String) e.nextElement();
95 sb.append("\n\t").append(key).append("=")
96 .append(isPW(key) ? "<password suppressed>" : ics.GetSSVar(key));
97 }
98 LOG.trace(sb.toString());
99 }
100 String s = ics.runTag(tagName, list);
101 if (LOG.isTraceEnabled()) {
102 StringBuffer sb = new StringBuffer("Just completed execution of runTag for tag: " + tagName + ". ");
103 sb.append("\nInput param list:");
104 for (Object k : list.keySet()) {
105 String key = (String) k;
106 sb.append("\n\t").append(key).append("=")
107 .append(isPW(key) ? "<password suppressed>" : list.getValString(key));
108 }
109 sb.append("\nVariables:");
110 Enumeration<?> e = ics.GetVars();
111 while (e.hasMoreElements()) {
112 String key = (String) e.nextElement();
113 sb.append("\n\t").append(key).append("=").append(isPW(key) ? "<password suppressed>" : ics.GetVar(key));
114 }
115 sb.append("\nSession Variables:");
116 e = ics.GetSSVars();
117 while (e.hasMoreElements()) {
118 String key = (String) e.nextElement();
119 sb.append("\n\t").append(key).append("=")
120 .append(isPW(key) ? "<password suppressed>" : ics.GetSSVar(key));
121 }
122 LOG.trace(sb.toString());
123 }
124 postExecute(ics);
125 if (ics.GetErrno() < 0 && ics.GetErrno()!=-101) {
126 this.handleError(ics);
127 }
128 return s;
129 }
130
131 private static final boolean isPW(String key) {
132 return key != null && key.toLowerCase().contains("password");
133 }
134
135
136
137
138
139
140
141
142
143 protected void preExecute(ICS ics) {
144
145 }
146
147
148
149
150
151
152
153
154 protected void postExecute(ICS ics) {
155
156 }
157
158
159
160
161
162
163
164
165
166
167 protected void handleError(ICS ics) {
168 throw new TagRunnerRuntimeException("ics.runTag(" + tagName + ") returned an errno.", ics.GetErrno(), list,
169 ics.getComplexError(), ics.GetVar("pagename"), ics.ResolveVariables("CS.elementname"));
170
171 }
172 }