Skip to content

Commit f59b01b

Browse files
committed
Channel Columns in the UI works
Signed-off-by: Nico Piel <[email protected]>
1 parent 4bace95 commit f59b01b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

server/src/com/mirth/connect/server/util/javascript/JavaScriptTask.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.apache.commons.lang3.StringUtils;
1515
import org.apache.logging.log4j.LogManager;
1616
import org.apache.logging.log4j.Logger;
17+
import org.apache.logging.log4j.ThreadContext;
1718
import org.mozilla.javascript.Context;
1819
import org.mozilla.javascript.Script;
1920
import org.mozilla.javascript.Scriptable;
@@ -28,6 +29,8 @@ public abstract class JavaScriptTask<T> implements Callable<T> {
2829
private Logger logger = LogManager.getLogger(JavaScriptTask.class);
2930
private MirthContextFactory contextFactory;
3031
private String threadName;
32+
private String channelId;
33+
private String channelName;
3134
private Context context;
3235
private boolean contextCreated = false;
3336

@@ -74,6 +77,9 @@ private JavaScriptTask(MirthContextFactory contextFactory) {
7477
}
7578

7679
private void init(String name, String channelId, String channelName, Integer metaDataId, String destinationName) {
80+
this.channelId = channelId;
81+
this.channelName = channelName;
82+
7783
StringBuilder builder = new StringBuilder(name).append(" JavaScript Task");
7884
if (StringUtils.isNotEmpty(channelName)) {
7985
builder.append(" on ").append(channelName);
@@ -111,8 +117,22 @@ public final T call() throws Exception {
111117
String originalThreadName = Thread.currentThread().getName();
112118
try {
113119
Thread.currentThread().setName(threadName + " < " + originalThreadName);
120+
121+
if (channelId != null) {
122+
ThreadContext.put("channelId", channelId);
123+
}
124+
if (channelName != null) {
125+
ThreadContext.put("channelName", channelName);
126+
}
127+
114128
return doCall();
115129
} finally {
130+
if (channelName != null) {
131+
ThreadContext.remove("channelName");
132+
}
133+
if (channelId != null) {
134+
ThreadContext.remove("channelId");
135+
}
116136
Thread.currentThread().setName(originalThreadName);
117137
}
118138
}

0 commit comments

Comments
 (0)