This commit is contained in:
Rinjae
2025-09-05 17:16:26 +09:00
commit c54ef1903f
4947 changed files with 817291 additions and 0 deletions
@@ -0,0 +1,66 @@
package com.eactive.eai.agent.command;
import java.io.Serializable;
import java.util.Map;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
@SuperBuilder
@Accessors(chain = true)
public abstract class Command implements Serializable {
private static final long serialVersionUID = 1L;
@Getter
@Setter
@NonNull
protected String name;
@Setter
protected Object args;
private Map<String, String> errorCode;
protected Command() {
this.name = this.getClass().getName();
}
protected Command(String name) {
this.name = name;
}
public abstract Object execute() throws CommandException;
protected String makeException(String rspErrorCode, Throwable cause) {
String[] msgArgs = new String[2];
msgArgs[0] = name;
if (cause == null) {
msgArgs[1] = args.toString();
} else {
msgArgs[1] = cause.getMessage();
}
return makeMessage(errorCode.get(rspErrorCode), msgArgs);
}
private static String makeMessage(String msg, String[] args) {
String keyword = null;
String head = null;
String tail = null;
int idx = -1;
for (int i = 0; i < args.length; i++) {
keyword = "{" + (i + 1) + "}";
idx = msg.indexOf(keyword);
if (idx == -1) {
continue;
}
head = msg.substring(0, idx);
tail = msg.substring(idx + keyword.length());
msg = head + args[i] + tail;
}
return msg;
}
}
@@ -0,0 +1,43 @@
package com.eactive.eai.agent.command;
/**
* 1. 기능 : Command Logic을 실행하다 발생될 User Define 오류를 처리하기 위한 Exception class<br>
* 2. 처리 개요 : Command Logic을 실행하다 발생될 User Define 오류를 처리하기 위한 Exception class<br>
* 3. 주의사항
*
* @author
* @version v 1.0.0
* @see 관련 기능을 참조
* @since
*
*/
public class CommandException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 1. 기능 : Default Constructor
* 2. 처리 개요 : Default Constructor
* 3. 주의사항
*
**/
public CommandException() {
super("CommandException is occured.");
}
/**
* 1. 기능 : Exception message를 초기화하는 Constructor
* 2. 처리 개요 : Exception message를 초기화하는 Constructor
* -
* 3. 주의사항
*
* @param msg Exception message
**/
public CommandException(String msg) {
super(msg);
}
}
@@ -0,0 +1,22 @@
package com.eactive.eai.agent.command;
import java.util.Map;
import com.eactive.eai.rms.common.util.CommonUtil;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class CommandResult {
@Getter
@NonNull
private Map<String, Object> result;
public String getMessage(boolean newLineBetweenEntries) {
return CommonUtil.getMapString(result, newLineBetweenEntries);
}
}
@@ -0,0 +1,80 @@
package com.eactive.eai.agent.command;
import java.lang.reflect.Constructor;
import com.eactive.eai.rms.onl.common.exception.EMSRuntimeException;
import com.eactive.eai.rms.onl.common.service.AgentUtilService;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
@SuperBuilder
@NoArgsConstructor
public class CommonCommand extends Command {
private static final long serialVersionUID = 1L;
public static final String RELOAD_EAI_MESSAGE_COMMAND = "com.eactive.eai.agent.eaimessage.ReloadEAIMessageCommand";
public static final String RELOAD_TRANSFORM_COMMAND = "com.eactive.eai.agent.transformer.ReloadTransformCommand";
public static final String REMOVE_TRANSFORM_COMMAND = "com.eactive.eai.agent.transformer.RemoveTransformCommand";
public static final String RELOAD_TRANSFORM_LIST_COMMAND = "com.eactive.eai.agent.transformer.ReloadTransformListCommand";
public static final String RELOAD_MESSAGE_KEY_COMMAND = "com.eactive.eai.agent.messagekey.ReloadMessageKeyCommand";
public static final String REMOVE_MESSAGE_KEY_COMMAND = "com.eactive.eai.agent.messagekey.RemoveMessageKeyCommand";
public static final String RELOAD_EAI_SERVER_COMMAND = "com.eactive.eai.agent.eaiserver.ReloadEAIServerCommand";
public static final String REMOVE_EAI_SERVER_COMMAND = "com.eactive.eai.agent.eaiserver.RemoveEAIServerCommand";
public static final String RELOAD_SUB_MESSAGE_COMMAND = "com.ext.eai.agent.submessage.ReloadSubMessageCommand";
public static final String REMOVE_SUB_MESSAGE_COMMAND = "com.ext.eai.agent.submessage.RemoveSubMessageCommand";
public static final String RELOAD_CLIENT_COMMAND = "com.eactive.eai.agent.authserver.ReloadClientCommand";
public static final String RELOAD_API_SCOPE_COMMAND = "com.eactive.eai.agent.authserver.ReloadApiScopeCommand";
public static final String RELOAD_ERROR_CODE_COMMAND = "com.eactive.eai.agent.errorcode.ReloadErrorCodeCommand";
public static final String REMOVE_ERROR_CODE_COMMAND = "com.eactive.eai.agent.errorcode.RemoveErrorCodeCommand";
public CommonCommand(String name, Object args) {
this.name = name;
this.args = args;
}
public CommonCommand(String name) {
this.name = name;
}
public Object execute() throws CommandException {
if (name.indexOf(".") >= 0) {
try {
@SuppressWarnings("rawtypes")
Class cl = Class.forName(this.name);
@SuppressWarnings({ "rawtypes", "unchecked" })
Constructor constructor = cl.getConstructor();
Object obj = constructor.newInstance();
Command c = (Command) obj;
c.setArgs(args);
return c.execute();
} catch (Exception e) {
String rspErrorCode = "RECEAIMCM002";
String msg = makeException(rspErrorCode, null);
throw new CommandException(msg);
}
} else {
String rspErrorCode = "RECEAIMCM001";
String msg = makeException(rspErrorCode, null);
throw new CommandException(msg);
}
}
public CommandResult broadcast(AgentUtilService agentUtilService) throws EMSRuntimeException {
try {
return new CommandResult(agentUtilService.broadcast(this));
} catch (Exception e) {
throw new EMSRuntimeException(e);
}
}
}