132 lines
5.5 KiB
Java
132 lines
5.5 KiB
Java
//package com.eactive.eai.inbound.remote;
|
|
//
|
|
//import java.util.ArrayList;
|
|
//import org.apache.commons.net.ftp.FTPClient;
|
|
//import org.apache.commons.net.ftp.FTPFile;
|
|
//import org.apache.commons.net.ftp.FTPReply;
|
|
//
|
|
//public class FTPTransferByApi extends CommonTransfer
|
|
//{
|
|
//
|
|
// private FTPClient ftpClient = null;
|
|
//
|
|
//
|
|
// //-------------------------------------------------------------------------------------------
|
|
// //
|
|
// //-------------------------------------------------------------------------------------------
|
|
// private void connect(RemoteServerVO remoteServerVO) throws Exception {
|
|
//
|
|
// try {
|
|
// String remoteServerIP = remoteServerVO.getRemoteServerIP();
|
|
// String remoteFtpPort = remoteServerVO.getRemoteFtpPort();
|
|
//
|
|
// if (remoteFtpPort.equals("")) {
|
|
// logger.warn("[리모트송수신] [FTP_Api] 해당 서버["+ remoteServerIP +"] 에 연결할 FTP 포트번호가 주어지지 않았습니다. 디폴트 포트번호 '21' 을 설정합니다.");
|
|
// remoteFtpPort = "21";
|
|
// }
|
|
// logger.info("[리모트송수신] [FTP_Api] ▶ FTP 서버 연결 시도... " + remoteServerIP + ":" + remoteFtpPort);
|
|
//
|
|
//
|
|
// if (ftpClient!=null && ftpClient.isConnected()) {
|
|
// logger.info("[리모트송수신] [FTP_Api] ▶ 해당 FTP 서버에 이미 연결되어 있습니다.");
|
|
// return;
|
|
// }
|
|
//
|
|
// ftpClient = new FTPClient();
|
|
// ftpClient.setControlEncoding("EUC-KR");
|
|
// ftpClient.connect(remoteServerIP, Integer.parseInt(remoteFtpPort));
|
|
//
|
|
// int reply = ftpClient.getReplyCode();
|
|
// logger.info("[리모트송수신] [FTP_Api] ☞ 응답코드 : "+ reply);
|
|
//
|
|
// if (!FTPReply.isPositiveCompletion(reply)) {
|
|
// try {
|
|
// logger.error("[리모트송수신] [FTP_Api] FTP 서버 연결에 실패하였습니다.");
|
|
// ftpClient.disconnect();
|
|
//
|
|
// } catch (Exception ex) {
|
|
// logger.error( ex.getMessage(), ex);
|
|
// }
|
|
// throw new Exception("FTP 연결 응답코드("+ reply +") 가 비정상입니다.");
|
|
// }
|
|
// logger.info("[리모트송수신] [FTP_Api] ▶ FTP 서버에 연결되었습니다.");
|
|
//
|
|
// } catch (Exception ex) {
|
|
// logger.error( ex.getMessage(), ex);
|
|
// throw new Exception("FTP 연결 오류!\n caused by..."+ ex.toString());
|
|
// }
|
|
// }
|
|
//
|
|
// //-------------------------------------------------------------------------------------------
|
|
// //
|
|
// //-------------------------------------------------------------------------------------------
|
|
// private void disconnect() {
|
|
// logger.info("[리모트송수신] [FTP_Api] ▶ FTP 서버 연결 해제 시도...");
|
|
// try {
|
|
// if (ftpClient!=null && ftpClient.isConnected()) ftpClient.disconnect();
|
|
// logger.info("[리모트송수신] [FTP_Api] ▶ FTP 서버 연결이 해제 되었습니다.");
|
|
// } catch (Exception ex) {
|
|
// logger.error( ex.getMessage(), ex);
|
|
// }
|
|
// }
|
|
//
|
|
// //-------------------------------------------------------------------------------------------
|
|
// //
|
|
// //-------------------------------------------------------------------------------------------
|
|
// public ArrayList<TargetFileVO> listFiles(RemoteServerVO remoteServerVO, String remoteDir) throws Exception {
|
|
//
|
|
// logger.info("[리모트송수신] [FTP_Api] ■ 리모트 파일 목록 조회 시작...... (Component 사용)");
|
|
// logger.info("[리모트송수신] [FTP_Api] ⓟ 리모트 경로 : ["+ remoteDir +"]");
|
|
//
|
|
// //파라미터 체크
|
|
// if (remoteServerVO == null) throw new Exception("{리모트서버 VO} 파라미터 오류");
|
|
// if (remoteDir.equals("")) throw new Exception("{리모트경로} 파라미터 오류");
|
|
//
|
|
// ArrayList<TargetFileVO> alist = new ArrayList<TargetFileVO>();
|
|
//
|
|
// try {
|
|
// if (ftpClient == null || !ftpClient.isConnected()) this.connect(remoteServerVO);
|
|
//
|
|
// ftpClient.login(remoteServerVO.getRemoteUserId(), remoteServerVO.getRemotePassword());
|
|
//
|
|
// FTPFile[] files = ftpClient.listFiles(remoteDir);
|
|
// logger.info("[리모트송수신] [FTP_Api] ☞ 리모트 파일 건수 : ["+ files.length +"]");
|
|
//
|
|
// for (int i=0; i<files.length; i++) {
|
|
// TargetFileVO info = new TargetFileVO();
|
|
// info.setName (files[i].getName());
|
|
// info.setSize (files[i].getSize());
|
|
// info.setLastModified (files[i].getTimestamp().getTimeInMillis());
|
|
// info.setDirectory (files[i].isDirectory());
|
|
// info.setFile (files[i].isFile());
|
|
// alist.add(info);
|
|
// }
|
|
//
|
|
// } catch (Exception ex) {
|
|
// logger.error( ex.getMessage(), ex);
|
|
// throw new Exception("FTP 파일 목록 조회 실패!\n caused by..."+ ex.toString());
|
|
//
|
|
// } finally {
|
|
// this.disconnect();
|
|
// }
|
|
//
|
|
// logger.info("[리모트송수신] [FTP_Api] ■ 리모트 파일 목록 조회 완료.");
|
|
// return alist;
|
|
// }
|
|
//
|
|
// //-------------------------------------------------------------------------------------------
|
|
// //
|
|
// //-------------------------------------------------------------------------------------------
|
|
// public void sendFile(RemoteServerVO remoteServerVO, String eaiDir, String eaiFile, String remoteDir, String remoteFile) throws Exception {
|
|
// throw new Exception("Component 에 의한 EAI->Remote FTP 송신이 구현되지 않았습니다.");
|
|
// }
|
|
//
|
|
// //-------------------------------------------------------------------------------------------
|
|
// //
|
|
// //-------------------------------------------------------------------------------------------
|
|
// public void receiveFile(RemoteServerVO remoteServerVO, String remoteDir, String remoteFile, String eaiDir, String eaiFile) throws Exception {
|
|
// throw new Exception("Component 에 의한 Remote->EAI FTP 수신이 구현되지 않았습니다.");
|
|
// }
|
|
//
|
|
//}
|