support set agent id with request

pull/1490/merge^2
gongdewei 4 years ago
parent 24efdfa6b9
commit 59a215fc44

@ -49,11 +49,19 @@ public class LegacyApiController {
@Autowired @Autowired
private ApiActionDelegateService apiActionDelegateService; private ApiActionDelegateService apiActionDelegateService;
@RequestMapping("/legacy_api/{agentId}") @RequestMapping({"/legacy_api/{agentId}", "/legacy_api"})
public Mono<ApiResponse> process(@PathVariable String agentId, @RequestBody ApiRequest request) { public Mono<ApiResponse> process(@PathVariable(required = false) String agentId, @RequestBody ApiRequest request) {
try { try {
// check agentId
if (StringUtils.hasText(request.getAgentId())) {
if (agentId != null && !agentId.equals(request.getAgentId())) {
throw new IllegalArgumentException("Inconsistent agentId in path and request: " + agentId + ", " + request.getAgentId());
}
agentId = request.getAgentId();
}
checkAgentExists(agentId); checkAgentExists(agentId);
request.setAgentId(agentId);
// set default exec timeout // set default exec timeout
if (request.getExecTimeout() == null) { if (request.getExecTimeout() == null) {

@ -10,6 +10,7 @@ public class ApiRequest {
private String action; private String action;
private String command; private String command;
private String requestId; private String requestId;
private String agentId;
private String sessionId; private String sessionId;
private String consumerId; private String consumerId;
private Integer execTimeout; private Integer execTimeout;
@ -18,11 +19,12 @@ public class ApiRequest {
public String toString() { public String toString() {
return "ApiRequest{" + return "ApiRequest{" +
"action='" + action + '\'' + "action='" + action + '\'' +
", command='" + command + '\'' + (command != null ? ", command='" + command + '\'' : "") +
", requestId='" + requestId + '\'' + (requestId != null ? ", requestId='" + requestId + '\'' : "") +
", sessionId='" + sessionId + '\'' + (agentId != null ? ", agentId='" + agentId + '\'' : "") +
", consumerId='" + consumerId + '\'' + (sessionId != null ? ", sessionId='" + sessionId + '\'' : "") +
", execTimeout=" + execTimeout + (consumerId != null ? ", consumerId='" + consumerId + '\'' : "") +
(execTimeout != null ? ", execTimeout=" + execTimeout : "") +
'}'; '}';
} }
@ -50,6 +52,14 @@ public class ApiRequest {
this.requestId = requestId; this.requestId = requestId;
} }
public String getAgentId() {
return agentId;
}
public void setAgentId(String agentId) {
this.agentId = agentId;
}
public String getSessionId() { public String getSessionId() {
return sessionId; return sessionId;
} }

Loading…
Cancel
Save