Package org.jboss.soa.esb.util

Examples of org.jboss.soa.esb.util.RemoteFileSystem


   *
   * @see org.jboss.soa.esb.notification.NotificationTarget#sendNotification(org.jboss.soa.esb.message.Message)
   */
  public void sendNotification(Message message) throws NotificationException {
    File fileToSend = null;
    RemoteFileSystem rfs = null;
    try {
      fileToSend = getFileToSend( message );
      rfs = RemoteFileSystemFactory.getRemoteFileSystem(getFtpEpr(), true);
      rfs.uploadFile(fileToSend, getFileName(message));
    } catch (RemoteFileSystemException e) {
      throw new NotificationException("Could not complete FTP notification", e);
    } catch (IOException e) {
      throw new NotificationException("Could not complete FTP notification", e);
    } finally {
      if (fileToSend != null) {
        fileToSend.delete();
      }
      if (rfs != null) {
        rfs.quit();
      }
    }
  }
View Full Code Here


    try
    {
            EPR epr = ListenerUtil.assembleEpr(config);
      if (epr instanceof FTPEpr)  {
        FTPEpr ftpEpr = (FTPEpr) epr;
        RemoteFileSystem rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
        rfs.quit();
      } else {
        throw new GatewayException("This Gateway only accepts FTP and SFTP.");
      }
    }
    catch (RemoteFileSystemException ex)
View Full Code Here

  }

  @Override
  public boolean deleteFile(File file) throws GatewayException
  {
    RemoteFileSystem rfs = null;
    try
    {
      EPR epr = ListenerUtil.assembleEpr(config);
      if (epr instanceof FTPEpr)  {
        FTPEpr ftpEpr = (FTPEpr) epr;
        rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
        rfs.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));
        rfs.deleteRemoteFile(file.toString());
        return true;
      } else {
        throw new GatewayException("This Gateway only accepts FTP and SFTP.");
      }
     
    } catch (Exception e)
    {
      throw new GatewayException(e);
    } finally
    {
      if (null != rfs)
        rfs.quit();
    }
  }
View Full Code Here

  }

    @Override
  byte[] getFileContents(File file) throws GatewayException
  {
    RemoteFileSystem rfs = null;
    try
    {
      File temp = File.createTempFile("FTPdown", ".tmp");
      EPR epr = ListenerUtil.assembleEpr(config);
      if (epr instanceof FTPEpr)  {
        FTPEpr ftpEpr = (FTPEpr) epr;
        rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
        rfs.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));
        rfs.downloadFile(file.toString(), temp.getAbsolutePath());
        final byte[] contents = super.getFileContents(temp);
        temp.delete() ;
        return contents ;
      } else {
        throw new GatewayException("This Gateway only accepts FTP and SFTP.");
      }
     
    } catch (Exception e)
    {
      throw new GatewayException(e);
    } finally
    {
      if (null != rfs)
        rfs.quit();
    }
  }
View Full Code Here

    }

    @Override
  File[] getFileList() throws GatewayException
  {
    RemoteFileSystem rfs = null;
    File[] oaRet = null;
    try
    {
      EPR epr = ListenerUtil.assembleEpr(config);
      if (epr instanceof FTPEpr)  {
        FTPEpr ftpEpr = (FTPEpr) epr;
        rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
        rfs.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));
        String[] sa = rfs.getFileListFromRemoteDir(_inputSuffix);
        oaRet = new File[(null == sa) ? 0 : sa.length];
        int i1 = 0;
        if (null != sa)
          for (String sCurr : sa)
            oaRet[i1++] = new File(sCurr);
      } else {
        throw new GatewayException("This Gateway only accepts FTP and SFTP.");
      }
    } catch (Exception e){
      throw new GatewayException(e);
    } finally {
      if (null != rfs)
        rfs.quit();
    }
    return oaRet;
  }
View Full Code Here

  }

  @Override
  boolean renameFile(File from, File to) throws GatewayException
  {
    RemoteFileSystem rfs = null;
    try
    {
      EPR epr = ListenerUtil.assembleEpr(config);
      if (epr instanceof FTPEpr)  {
        FTPEpr ftpEpr = (FTPEpr) epr;
        rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
        rfs.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));
        rfs.remoteRename( from, to );
        return true;
      } else {
        throw new GatewayException("This Gateway only accepts FTP and SFTP.");
      }
    } catch (Exception e) {
      throw new GatewayException(e);
    } finally {
      if (null != rfs)
        rfs.quit();
    }
  }
View Full Code Here

  }
 
  @Override
  void bytesToFile(byte[] bytes, File file) throws GatewayException
  {
    RemoteFileSystem rfs = null;
    try
    {
      EPR epr = ListenerUtil.assembleEpr(config);
      if (!(epr instanceof FTPEpr)) 
        throw new Exception("This Gateway only accepts FTP and SFTP.");

      FTPEpr ftpEpr = (FTPEpr) epr;
      rfs = RemoteFileSystemFactory.getRemoteFileSystem(ftpEpr, true);
      rfs.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));

      File tmpFile = File.createTempFile("RemoteGW", ".forUpload");
      super.bytesToFile(bytes, tmpFile);
      rfs.uploadFile(tmpFile, file.getName());
      tmpFile.delete();

    } catch (Exception e) {
      throw new GatewayException(e);
    } finally {
      if (null != rfs)
        rfs.quit();
    }
  }
View Full Code Here

        public boolean deleteFile(File file) throws CourierException
        {
                // TODO would be better to return false if the file did not exist and leave exceptions
                // for other error conditions (such as permission denied).
               
                final RemoteFileSystem handler = getHandler() ;
                try
                {
                        handler.deleteRemoteFile(file.getName());
                        return true;
                }
                catch (Exception e)
                {
                        e.printStackTrace();
                       
                        throw new CourierException(e);
                }
                finally
                {
                    handler.quit() ;
                }
        }
View Full Code Here

                                _logger.debug("FtpFileHandler.getFileContents on "+file+" will ignore because of directory.");
                       
                                return null;
                        }
                       
                        final RemoteFileSystem handler = getHandler() ;
                        try
                        {
                            handler.downloadFile(name, name);
                        }
                        finally
                        {
                            handler.quit() ;
                        }
                        File local = new File(_localDir, name);
                        byte[] ba = CourierUtil.bytesFromLocalFile(local);
                        if (!local.delete())
                        {
View Full Code Here

        public void uploadFile(File file) throws CourierException
        {
                try
                {
                        String name = file.getName();
                        final RemoteFileSystem handler = getHandler() ;
                        try
                        {
                            handler.uploadFile(file, name);
                        }
                        finally
                        {
                            handler.quit();
                        }
                        if (!file.delete())
                        {
                            _logger.warn("Could not delete file " + file.getCanonicalPath()) ;
                        }
View Full Code Here

TOP

Related Classes of org.jboss.soa.esb.util.RemoteFileSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.