Example #1
0
 private void closeConnection() {
   try {
     if (objVFS4Handler != null) {
       objVFS4Handler.CloseConnection();
       objVFS4Handler.CloseSession();
     }
   } catch (Exception e) {
     throw new JobSchedulerException(e);
   }
 }
Example #2
0
 private void doConnect(
     final ISOSVFSHandler objVFS4Handler, final SOSConnection2OptionsAlternate objConnectOptions) {
   try {
     objVFS4Handler.Connect(objConnectOptions);
   } catch (Exception e) { // Problem to connect, try alternate host
     // TODO respect alternate data-source type? alternate port etc. ?
     JobSchedulerException.LastErrorMessage = "";
     try {
       objVFS4Handler.Connect(objConnectOptions.Alternatives());
       objConnectOptions.setAlternateOptionsUsed("true");
     } catch (Exception e1) {
       throw new JobSchedulerException(e);
     }
     // TODO get an instance of .Alternatives for Authentication ...
   }
 }
Example #3
0
 private boolean isConnected() {
   boolean flgR = true;
   if (objVFS4Handler != null) {
     flgR = objVFS4Handler.isConnected();
   }
   return flgR;
 }
Example #4
0
 private void doAuthenticate(
     final ISOSVFSHandler objVFS4Handler,
     final SOSConnection2OptionsAlternate objConnectOptions,
     final boolean pflgIsDataSource)
     throws Exception {
   try {
     objVFS4Handler.Authenticate(objConnectOptions);
   } catch (Exception e) { // SOSFTP-113: Problem to login, try alternate User
     // TODO respect alternate authentication, eg password and/or public key
     JobSchedulerException.LastErrorMessage = "";
     try {
       objVFS4Handler.Authenticate(objConnectOptions.Alternatives());
     } catch (RuntimeException e1) {
       throw e1;
     }
     objConnectOptions.setAlternateOptionsUsed("true");
   }
   ISOSVfsFileTransfer objDataClient = (ISOSVfsFileTransfer) objVFS4Handler;
   if (objOptions.passive_mode.value() || objConnectOptions.passive_mode.isTrue()) {
     objDataClient.passive();
   }
   // objConnectOptions.transfer_mode is not used?
   if (objConnectOptions.transfer_mode.isDirty() && objConnectOptions.transfer_mode.IsNotEmpty()) {
     objDataClient.TransferMode(objConnectOptions.transfer_mode);
   } else {
     objDataClient.TransferMode(objOptions.transfer_mode);
   }
   objDataClient.ControlEncoding(objOptions.ControlEncoding.Value());
   // TODO pre-commands for source and target separately
   if (objOptions.PreFtpCommands.IsNotEmpty() && pflgIsDataSource == false) {
     // TODO Command separator as option
     for (String strCmd : objOptions.PreFtpCommands.split()) {
       strCmd = objOptions.replaceVars(strCmd);
       objDataClient.getHandler().ExecuteCommand(strCmd);
     }
   }
   if (objConnectOptions.PreFtpCommands.IsNotEmpty()) {
     // TODO Command separator as option
     for (String strCmd : objConnectOptions.PreFtpCommands.split()) {
       strCmd = objConnectOptions.replaceVars(strCmd);
       objDataClient.getHandler().ExecuteCommand(strCmd);
     }
   }
 }