|
|
|
|
@ -1,6 +1,11 @@
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
import java.sql.DriverManager;
|
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
|
|
|
|
@ -8,49 +13,95 @@ public class CustomSender {
|
|
|
|
|
|
|
|
|
|
public static final Logger logger = Logger.getLogger(CustomSender.class);
|
|
|
|
|
|
|
|
|
|
private static String[] g_strDB = new String[4];
|
|
|
|
|
private static String ofileName = "";
|
|
|
|
|
private static String wasWorkDir = "";
|
|
|
|
|
private static String webWorkDir = "";
|
|
|
|
|
private static String sujibWorkDir = "";
|
|
|
|
|
private static String finalDest = "";
|
|
|
|
|
private static String finalDestWorkDir = "";
|
|
|
|
|
private static String fileId = "";
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
String fileName = args[0];
|
|
|
|
|
if(args.length != 4) {
|
|
|
|
|
System.err.println("총 4개의 args를 입력하지 않았습니다.");
|
|
|
|
|
System.exit(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ofileName = args[0];
|
|
|
|
|
wasWorkDir = args[1];
|
|
|
|
|
webWorkDir = args[2];
|
|
|
|
|
sujibWorkDir = args[3];
|
|
|
|
|
finalDestWorkDir = args[4];
|
|
|
|
|
finalDest = args[5];
|
|
|
|
|
fileId = args[3];
|
|
|
|
|
|
|
|
|
|
CustomSender self = new CustomSender();
|
|
|
|
|
// 프로퍼티 파일 위치
|
|
|
|
|
String propFile = "/gpta/source-app/cfs/relay_jar/config.properties";
|
|
|
|
|
// 프로퍼티 파일 로딩
|
|
|
|
|
try {
|
|
|
|
|
// 프로퍼티 객체 생성
|
|
|
|
|
Properties props = new Properties();
|
|
|
|
|
|
|
|
|
|
// 프로퍼티 파일 스트림에 담기
|
|
|
|
|
FileInputStream fis = new FileInputStream(propFile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
props.load(new java.io.BufferedInputStream(fis));
|
|
|
|
|
|
|
|
|
|
File file = new File(wasWorkDir + "/" + fileName);
|
|
|
|
|
|
|
|
|
|
int ftpResult = self.setFtpData(file, fileName);
|
|
|
|
|
// 항목 읽기
|
|
|
|
|
g_strDB[0] = props.getProperty("db_driver");
|
|
|
|
|
g_strDB[1] = props.getProperty("db_connect");
|
|
|
|
|
g_strDB[2] = props.getProperty("db_id");
|
|
|
|
|
g_strDB[3] = props.getProperty("db_pw");
|
|
|
|
|
|
|
|
|
|
if(ftpResult != -1) {
|
|
|
|
|
self.deliveryReq(
|
|
|
|
|
webWorkDir+"/"+file.getName(),
|
|
|
|
|
sujibWorkDir+"/"+file.getName(),
|
|
|
|
|
finalDestWorkDir+"/"+file.getName(),
|
|
|
|
|
finalDest
|
|
|
|
|
);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomSender self = new CustomSender();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
self.run();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void deliveryReq(String srcPath, String layoverPath, String destPath, String destName) {
|
|
|
|
|
FTPUtil ssh = new FTPUtil();
|
|
|
|
|
ssh.initExec("175.193.201.56", "tmax","tmax1234");
|
|
|
|
|
|
|
|
|
|
ssh.run("curl --insecure -X GET "
|
|
|
|
|
+ "d \"srcPath="+srcPath+"&layoverPath="+layoverPath+"&destPath="+destPath+"&from=web4&to="+destName+"\" "
|
|
|
|
|
+ "http://192.168.201.120/deliveryReq.do"
|
|
|
|
|
);
|
|
|
|
|
private void run() throws Exception {
|
|
|
|
|
File file = new File(wasWorkDir + "/" + ofileName);
|
|
|
|
|
|
|
|
|
|
int ftpResult = this.setFtpData(file, ofileName);
|
|
|
|
|
|
|
|
|
|
if(ftpResult == -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connection conn = null;
|
|
|
|
|
PreparedStatement ps = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn = getOrclConn();
|
|
|
|
|
|
|
|
|
|
String sql = "UPDATE TB_CUSTOM_COMMAND "
|
|
|
|
|
+ " SET STAT_CD = '1' "
|
|
|
|
|
+ " WHERE FILE_ID = '"+fileId+"' ";
|
|
|
|
|
ps = conn.prepareStatement(sql);
|
|
|
|
|
ps.executeUpdate();
|
|
|
|
|
conn.commit();
|
|
|
|
|
|
|
|
|
|
ssh.disconnectSession();
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}finally{
|
|
|
|
|
|
|
|
|
|
if(ps != null) {
|
|
|
|
|
ps.close();
|
|
|
|
|
}
|
|
|
|
|
conn.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int setFtpData(File file, String fileNm) {
|
|
|
|
|
|
|
|
|
|
FTPUtil sftp = new FTPUtil();
|
|
|
|
|
@ -79,4 +130,9 @@ public class CustomSender {
|
|
|
|
|
return nReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Connection getOrclConn( ) throws Exception{
|
|
|
|
|
Class.forName(g_strDB[0]);
|
|
|
|
|
return DriverManager.getConnection(g_strDB[1], g_strDB[2], g_strDB[3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|