Skip to content

Commit 6886e3f

Browse files
author
Yang Guo
committed
escape space for cmd id
1 parent 2ff5668 commit 6886e3f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

platform-api/src/main/java/com/flow/platform/api/consumer/CmdLoggingConsumer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
7878

7979
if (category.equals(CmdType.SYSTEM_INFO.toString())) {
8080
sendAgentSysInfo(content);
81-
return;
8281
}
8382
}
8483

@@ -89,7 +88,6 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
8988
* @param number
9089
*/
9190
private void sendCmdLog(String cmdId, String content, String number) {
92-
9391
String event = String.format("/topic/cmd/%s", cmdId);
9492
template.convertAndSend(event, "{\"number\": \"" + number + "\", \"content\": \"" + content + "\"}");
9593
}

platform-api/src/main/java/com/flow/platform/api/service/job/NodeResultServiceImpl.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public class NodeResultServiceImpl extends ApplicationEventService implements No
5454

5555
private final static Logger LOGGER = new Logger(NodeResultService.class);
5656

57+
private final static char SPACE_REPLACE = '_';
58+
5759
@Autowired
5860
private NodeResultDao nodeResultDao;
5961

@@ -194,15 +196,24 @@ private NodeResult createNodeResult(Job job, NodeTree nodeTree, Node node) {
194196

195197
// generate cc agent cmd id if node is runnable
196198
if (nodeTree.canRun(node.getPath())) {
197-
String agentCmdId = nodeResult.getKey().getJobId() + "-" + nodeResult.getKey().getPath();
198-
nodeResult.setCmdId(agentCmdId);
199+
nodeResult.setCmdId(createAgentCmdId(nodeResult));
199200
}
200201

201202
nodeResult.setName(node.getName());
202203
nodeResult.setNodeTag(node instanceof Flow ? NodeTag.FLOW : NodeTag.STEP);
203204
return nodeResult;
204205
}
205206

207+
/**
208+
* Create anget cmd id by job id and node path
209+
* @param nodeResult
210+
* @return
211+
*/
212+
private String createAgentCmdId(NodeResult nodeResult) {
213+
NodeResultKey key = nodeResult.getKey();
214+
return key.getJobId() + "-" + key.getPath().replace(' ', SPACE_REPLACE);
215+
}
216+
206217
private NodeStatus updateCurrent(Node current, NodeResult currentResult, Cmd cmd, String errorMsg) {
207218
boolean isAllowFailure = false;
208219
if (current instanceof Step) {

0 commit comments

Comments
 (0)