|
|
|
|
@ -3,12 +3,15 @@ package com.bsmlab.dfx.agent.listener.service;
|
|
|
|
|
import com.bsmlab.dfx.agent.config.AgentConfigDto;
|
|
|
|
|
import com.bsmlab.dfx.agent.config.AgentConfigReader;
|
|
|
|
|
import com.bsmlab.dfx.agent.listener.dto.AckDto;
|
|
|
|
|
import com.bsmlab.dfx.agent.listener.dto.CommandDto;
|
|
|
|
|
import com.bsmlab.dfx.agent.listener.dto.ReceiveMessageDto;
|
|
|
|
|
import com.bsmlab.dfx.agent.support.MessageUtils;
|
|
|
|
|
import com.bsmlab.dfx.agent.support.exception.IllegalMessageException;
|
|
|
|
|
import com.bsmlab.dfx.agent.support.exception.InCompleteMessageException;
|
|
|
|
|
import com.bsmlab.dfx.agent.support.exception.NullMessageException;
|
|
|
|
|
import com.bsmlab.dfx.agent.task.dropbox.DropBoxService;
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import jakarta.servlet.http.Part;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
@ -118,4 +121,30 @@ public class ListenerService {
|
|
|
|
|
}
|
|
|
|
|
return ackDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AckDto receiveCommand(String messageJsonString) {
|
|
|
|
|
AckDto ackDto;
|
|
|
|
|
CommandDto commandDto;
|
|
|
|
|
try {
|
|
|
|
|
commandDto = MessageUtils.toCommandDto(messageJsonString);
|
|
|
|
|
String resultText = null;
|
|
|
|
|
if(CommandDto.CommandType.ALIVE == commandDto.getCommandType()) {
|
|
|
|
|
resultText = "ALIVE";
|
|
|
|
|
}
|
|
|
|
|
else if(CommandDto.CommandType.INFORMATION == commandDto.getCommandType()) {
|
|
|
|
|
AgentConfigDto agentConfigDto = this.agentConfigReader.getAgentConfigDto();
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
try {
|
|
|
|
|
resultText = objectMapper.writeValueAsString(agentConfigDto);
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
resultText = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ackDto = AckDto.builder().result(AckDto.ResultType.PROCESS_SUCCESS).messageUuid(commandDto.getMessageUuid()).resultText(resultText).build();
|
|
|
|
|
}
|
|
|
|
|
catch (IllegalMessageException | NullMessageException e) {
|
|
|
|
|
ackDto = AckDto.builder().result(AckDto.ResultType.RECEIVE_FAIL).resultText(e.getLocalizedMessage()).messageUuid("").build();
|
|
|
|
|
}
|
|
|
|
|
return ackDto;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|