Files
elink-online-common/src/main/java/com/kbstar/eai/common/header/CSSKISHeaderAction.java
T
Rinjae aacc1a389e init
2025-09-05 18:57:45 +09:00

139 lines
5.8 KiB
Java

package com.kbstar.eai.common.header;
import com.eactive.eai.common.header.HeaderActionSupport;
/**
* 1. 기능 : CSSKIS의 Header를 EAI에서 생성하거나 삭제해야하는 경우를 위한 Class
* 2. 처리 개요 :
* - 메시지종류에 따라 헤더를 생성하거나 삭제하는 API를 제공
* 3. 주의사항
* - AD 의 경우는 S는 ADD, R 는 DELETE
* - DA 의 경우는 S는 DELETE, R 는 ADD
* @author :
* @version : v 1.0.0
* @see :
* @since :
*/
public class CSSKISHeaderAction extends HeaderActionSupport
{
private static final int HEADER_LENGTH = 6;
public CSSKISHeaderAction(){
super.setHeaderLength(HEADER_LENGTH);
}
public byte[] addHeaderDA(byte[] orgData , byte[] message) {
return addHeader(orgData,message);
}
public byte[] addHeaderAD(byte[] orgData , byte[] message) {
return addHeader(orgData,message);
}
public byte[] addHeader(byte[] orgData , byte[] message ) {
String header = "2C0003";
int headerLength = header.length();
int msgLength = message.length + headerLength;
byte[] retHeader = new byte[msgLength];
System.arraycopy(header.getBytes(), 0, retHeader, 0, headerLength);
System.arraycopy(message, 0, retHeader, headerLength, retHeader.length-headerLength);
return retHeader;
}
// public static void main(String args[]) throws Exception {
// test();
//}
// private static void test() throws Exception {
// String actionName = "com.kbstar.eai.common.header.CSSKISHeaderAction";
//
//
// /////전송 AD
// HeaderAction action = HeaderActionFactory.createAction(actionName);
//
// Object[] bizObjs =new Object[1];
// bizObjs[0] = "1234567890".getBytes();
// Object bizObj = null;
// if(bizObjs != null && bizObjs.length > 0) {
// bizObj = bizObjs[0];
// }
// byte[] orgData = null;
// System.out.println("orgData=>"+new String(orgData==null?"".getBytes():orgData));
// System.out.println("message=>"+new String(bizObj==null?"".getBytes():(byte[])bizObj));
// System.out.println("sendRecv=>"+HeaderActionKeys.MESSAGE_SEND);
// System.out.println("commandType=>"+HeaderActionKeys.ADD_DELETE_HEADER);
// byte[] header = action.excute(orgData ,(byte[])bizObj, HeaderActionKeys.MESSAGE_SEND, HeaderActionKeys.ADD_DELETE_HEADER);
// System.out.println("header=>"+new String(header));
/////////////
/////수신 AD
// HeaderAction action = HeaderActionFactory.createAction(actionName);
//
// Object[] bizObjs =new Object[1];
// bizObjs[0] = "0013HDR1234567890".getBytes();
// Object bizObj = null;
// if(bizObjs != null && bizObjs.length > 0) {
// bizObj = bizObjs[0];
// }
// byte[] orgData = null;
// //orgData = new byte[((byte[])bizObj).length ];
// //System.arraycopy(((byte[])bizObj), 0, orgData, 0,orgData.length);
// System.out.println("orgData=>"+new String(orgData==null?"".getBytes():orgData));
// System.out.println("message=>"+new String(bizObj==null?"".getBytes():(byte[])bizObj));
// System.out.println("sendRecv=>"+HeaderActionKeys.MESSAGE_RECV);
// System.out.println("commandType=>"+HeaderActionKeys.ADD_DELETE_HEADER);
//
// byte[] header = action.excute(orgData ,(byte[])bizObj, HeaderActionKeys.MESSAGE_RECV, HeaderActionKeys.ADD_DELETE_HEADER);
// System.out.println("header=>"+new String(header));
///////////////////////////////////////////
/////전송 DA
// HeaderAction action = HeaderActionFactory.createAction(actionName);
//
// Object[] bizObjs =new Object[1];
// bizObjs[0] = "0013HDR1234567890".getBytes();
// Object bizObj = null;
// if(bizObjs != null && bizObjs.length > 0) {
// bizObj = bizObjs[0];
// }
// byte[] orgData = null;
// orgData = new byte[((byte[])bizObj).length ];
// System.arraycopy(((byte[])bizObj), 0, orgData, 0,orgData.length);
// System.out.println("orgData=>"+new String(orgData==null?"".getBytes():orgData));
// System.out.println("message=>"+new String(bizObj==null?"".getBytes():(byte[])bizObj));
// System.out.println("sendRecv=>"+HeaderActionKeys.MESSAGE_SEND);
// System.out.println("commandType=>"+HeaderActionKeys.DELETE_ADD_HEADER);
// byte[] header = action.excute(orgData ,(byte[])bizObj, HeaderActionKeys.MESSAGE_SEND, HeaderActionKeys.DELETE_ADD_HEADER);
// System.out.println("header=>"+new String(header));
/////////////
/////수신 DA
// HeaderAction action = HeaderActionFactory.createAction(actionName);
//
// Object[] bizObjs =new Object[1];
// bizObjs[0] = "1234567890".getBytes();
// Object bizObj = null;
// if(bizObjs != null && bizObjs.length > 0) {
// bizObj = bizObjs[0];
// }
// byte[] orgData = null;
// orgData = new byte["0110200805021112280000000000010200X203 1370100000002SFX 1 1234567890".getBytes().length ];
// System.arraycopy("0110200805021112280000000000010200X203 1370100000002SFX 1 1234567890".getBytes(), 0, orgData, 0,orgData.length);
// System.out.println("orgData=>"+new String(orgData==null?"".getBytes():orgData));
// System.out.println("message=>"+new String(bizObj==null?"".getBytes():(byte[])bizObj));
// System.out.println("sendRecv=>"+HeaderActionKeys.MESSAGE_RECV);
// System.out.println("commandType=>"+HeaderActionKeys.DELETE_ADD_HEADER);
// byte[] header = action.excute(orgData ,(byte[])bizObj, HeaderActionKeys.MESSAGE_RECV, HeaderActionKeys.DELETE_ADD_HEADER);
// System.out.println("header=>"+new String(header));
// }
}