added logic for using two servers UCB and NABARD
This commit is contained in:
@@ -10,7 +10,8 @@ public class Main {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String user = "";
|
String user = "";
|
||||||
String password = "";
|
String password = "";
|
||||||
String host = "";
|
String hostUcb = "";
|
||||||
|
String hostNabard = "";
|
||||||
String local_folder_path = "";
|
String local_folder_path = "";
|
||||||
String local_archive_path = "";
|
String local_archive_path = "";
|
||||||
String local_report_path = "";
|
String local_report_path = "";
|
||||||
@@ -32,7 +33,8 @@ public class Main {
|
|||||||
}
|
}
|
||||||
prop.load(input);
|
prop.load(input);
|
||||||
|
|
||||||
host = prop.getProperty("REMOTE_HOST");
|
hostUcb = prop.getProperty("REMOTE_HOST_UCB");
|
||||||
|
hostNabard = prop.getProperty("REMOTE_HOST_NABARD");
|
||||||
user = prop.getProperty("REMOTE_USER");
|
user = prop.getProperty("REMOTE_USER");
|
||||||
password = prop.getProperty("REMOTE_PASS");
|
password = prop.getProperty("REMOTE_PASS");
|
||||||
port = Integer.parseInt(prop.getProperty("REMOTE_PORT"));
|
port = Integer.parseInt(prop.getProperty("REMOTE_PORT"));
|
||||||
@@ -49,8 +51,10 @@ public class Main {
|
|||||||
|
|
||||||
System.out.println("Config Properties read:");
|
System.out.println("Config Properties read:");
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"REMOTE_HOST: "
|
"REMOTE_HOST_UCB: "
|
||||||
+ host
|
+ hostUcb
|
||||||
|
+ "\nREMOTE_HOST_NABARD: "
|
||||||
|
+ hostNabard
|
||||||
+ "\nREMOTE_USER: "
|
+ "\nREMOTE_USER: "
|
||||||
+ user
|
+ user
|
||||||
+ "\nREMOTE_PASS: "
|
+ "\nREMOTE_PASS: "
|
||||||
@@ -74,27 +78,48 @@ public class Main {
|
|||||||
new SendLocalfile(
|
new SendLocalfile(
|
||||||
user,
|
user,
|
||||||
password,
|
password,
|
||||||
host,
|
hostUcb,
|
||||||
|
hostNabard,
|
||||||
local_folder_path,
|
local_folder_path,
|
||||||
remote_file_path,
|
remote_file_path,
|
||||||
transfer_protocol,
|
transfer_protocol,
|
||||||
port,
|
port,
|
||||||
local_archive_path);
|
local_archive_path);
|
||||||
FetchReportFile fetch =
|
FetchReportFile fetchUcb =
|
||||||
new FetchReportFile(
|
new FetchReportFile(
|
||||||
user,
|
user,
|
||||||
password,
|
password,
|
||||||
host,
|
hostUcb,
|
||||||
local_report_path,
|
local_report_path,
|
||||||
remote_report_path,
|
remote_report_path,
|
||||||
transfer_protocol,
|
transfer_protocol,
|
||||||
port,
|
port,
|
||||||
remote_report_pattern);
|
remote_report_pattern);
|
||||||
FetchReportFile fetchFailed =
|
FetchReportFile fetchNabard =
|
||||||
new FetchReportFile(
|
new FetchReportFile(
|
||||||
user,
|
user,
|
||||||
password,
|
password,
|
||||||
host,
|
hostNabard,
|
||||||
|
local_report_path,
|
||||||
|
remote_report_path,
|
||||||
|
transfer_protocol,
|
||||||
|
port,
|
||||||
|
remote_report_pattern);
|
||||||
|
FetchReportFile fetchFailedUcb =
|
||||||
|
new FetchReportFile(
|
||||||
|
user,
|
||||||
|
password,
|
||||||
|
hostUcb,
|
||||||
|
local_failed_path,
|
||||||
|
remote_failed_path,
|
||||||
|
transfer_protocol,
|
||||||
|
port,
|
||||||
|
remote_report_pattern);
|
||||||
|
FetchReportFile fetchFailedNabard =
|
||||||
|
new FetchReportFile(
|
||||||
|
user,
|
||||||
|
password,
|
||||||
|
hostNabard,
|
||||||
local_failed_path,
|
local_failed_path,
|
||||||
remote_failed_path,
|
remote_failed_path,
|
||||||
transfer_protocol,
|
transfer_protocol,
|
||||||
@@ -105,8 +130,10 @@ public class Main {
|
|||||||
while (true) {
|
while (true) {
|
||||||
System.out.println("___________________________________________________");
|
System.out.println("___________________________________________________");
|
||||||
send.sendFiles();
|
send.sendFiles();
|
||||||
fetch.fetchFiles();
|
fetchUcb.fetchFiles();
|
||||||
fetchFailed.fetchFiles();
|
fetchNabard.fetchFiles();
|
||||||
|
fetchFailedUcb.fetchFiles();
|
||||||
|
fetchFailedNabard.fetchFiles();
|
||||||
System.out.println("Sleeping for:" + sleep + " Minutes");
|
System.out.println("Sleeping for:" + sleep + " Minutes");
|
||||||
System.out.println("___________________________________________________");
|
System.out.println("___________________________________________________");
|
||||||
TimeUnit.MINUTES.sleep(sleep);
|
TimeUnit.MINUTES.sleep(sleep);
|
||||||
|
@@ -7,7 +7,8 @@ import com.sendFile.protocol.SSH.SSHProtocol;
|
|||||||
public class SendLocalfile {
|
public class SendLocalfile {
|
||||||
String user;
|
String user;
|
||||||
String password;
|
String password;
|
||||||
String host;
|
String hostUcb;
|
||||||
|
String hostNabard;
|
||||||
String local_folder_path;
|
String local_folder_path;
|
||||||
String archive_path;
|
String archive_path;
|
||||||
String remote_file_path;
|
String remote_file_path;
|
||||||
@@ -17,7 +18,8 @@ public class SendLocalfile {
|
|||||||
public SendLocalfile(
|
public SendLocalfile(
|
||||||
String user,
|
String user,
|
||||||
String password,
|
String password,
|
||||||
String host,
|
String hostUcb,
|
||||||
|
String hostNabard,
|
||||||
String local_folder_path,
|
String local_folder_path,
|
||||||
String remote_file_path,
|
String remote_file_path,
|
||||||
String transfer_protocol,
|
String transfer_protocol,
|
||||||
@@ -25,7 +27,8 @@ public class SendLocalfile {
|
|||||||
String archivePath) {
|
String archivePath) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.host = host;
|
this.hostUcb = hostUcb;
|
||||||
|
this.hostNabard = hostNabard;
|
||||||
this.local_folder_path = local_folder_path;
|
this.local_folder_path = local_folder_path;
|
||||||
this.remote_file_path = remote_file_path;
|
this.remote_file_path = remote_file_path;
|
||||||
this.transfer_protocol = transfer_protocol;
|
this.transfer_protocol = transfer_protocol;
|
||||||
@@ -40,13 +43,22 @@ public class SendLocalfile {
|
|||||||
for (File file : listOfFiles) {
|
for (File file : listOfFiles) {
|
||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
System.out.println("Going to send file: " + file.getAbsolutePath());
|
System.out.println("Going to send file: " + file.getAbsolutePath());
|
||||||
|
String bankCode = file.getName().split("-")[0];
|
||||||
|
String bankHost = "";
|
||||||
|
if(bankCode.equals("0005") || bankCode.equals("0021")) {
|
||||||
|
bankHost = hostNabard;
|
||||||
|
} else {
|
||||||
|
bankHost = hostUcb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.transfer_protocol.equals("SSH")) {
|
if (this.transfer_protocol.equals("SSH")) {
|
||||||
|
|
||||||
SSHProtocol ssh =
|
SSHProtocol ssh =
|
||||||
new SSHProtocol(
|
new SSHProtocol(
|
||||||
this.user,
|
this.user,
|
||||||
this.password,
|
this.password,
|
||||||
this.host,
|
bankHost,
|
||||||
this.port,
|
this.port,
|
||||||
file.getAbsolutePath(),
|
file.getAbsolutePath(),
|
||||||
this.remote_file_path,
|
this.remote_file_path,
|
||||||
@@ -59,7 +71,7 @@ public class SendLocalfile {
|
|||||||
new FTPProtocol(
|
new FTPProtocol(
|
||||||
this.user,
|
this.user,
|
||||||
this.password,
|
this.password,
|
||||||
this.host,
|
bankHost,
|
||||||
this.port,
|
this.port,
|
||||||
file.getAbsolutePath(),
|
file.getAbsolutePath(),
|
||||||
this.remote_file_path,
|
this.remote_file_path,
|
||||||
|
Reference in New Issue
Block a user