Class Filetransfer

java.lang.Object
com.swiftmq.filetransfer.Filetransfer
Direct Known Subclasses:
FiletransferImpl, FiletransferImpl

public abstract class Filetransfer extends Object

Reliable Filetransfer over JMS.

This class contains 2 factory methods to create a new Filetransfer object. One to send files, the other to receive files. A JMS connection is passed as a parameter. A new dedicated JMS session is created from this JMS connection to perform the transfer so files can be transferred by different Filetransfer objects in different threads. See the Filetransfer samples which are contained in the SwiftMQ documentation.

Have a look at the User's Guide

Author:
IIT Software GmbH, Bremen/Germany, (c) 2013, All Rights Reserved
  • Constructor Details

    • Filetransfer

      protected Filetransfer()
  • Method Details

    • create

      public static Filetransfer create(javax.jms.Connection connection, String routerName, String cacheName) throws FiletransferException, javax.jms.JMSException
      Creates a new Filetransfer which is connected to a filecache which is identified by router name and cache name.

      The returned Filetransfer object holds a dedicated JMS session which is created from the connection passed as parameter.

      Parameters:
      connection - JMS connection
      routerName - router name
      cacheName - cache name
      Returns:
      connected Filetransfer object
      Throws:
      FiletransferException - if there is an error during the file transfer
      javax.jms.JMSException - if there is an error during JMS access
    • create

      public static Filetransfer create(javax.jms.Connection connection, String link) throws FiletransferException, javax.jms.JMSException
      Creates a new Filetransfer which is connected to a filecache which is identified by a link.

      The returned Filetransfer object holds a dedicated JMS session which is created from the connection passed as parameter.

      Parameters:
      connection - JMS connection
      link - link to a file
      Returns:
      connected Filetransfer object
      Throws:
      FiletransferException - if there is an error during the file transfer
      javax.jms.JMSException - if there is an error during JMS access
    • request

      protected static MessageBasedReply request(MessageBasedRequest request, JMSAccessorHolder accessorHolder, MessageBasedFactory factory) throws FiletransferException, javax.jms.JMSException
      Throws:
      FiletransferException
      javax.jms.JMSException
    • request

      protected static MessageBasedReply request(MessageBasedRequest request, JMSAccessorHolder accessorHolder, MessageBasedFactory factory, Map<String,Object> properties) throws FiletransferException, javax.jms.JMSException
      Throws:
      FiletransferException
      javax.jms.JMSException
    • withFile

      public abstract Filetransfer withFile(File file)
      Sets the file to send or receive.
      Parameters:
      file - the file
      Returns:
      this Filetransfer object
    • withFilename

      public abstract Filetransfer withFilename(String filename)
      Overwrites the name of the file to send. So one can send a file under a different name.
      Parameters:
      filename - name the file
      Returns:
      this Filetransfer object
    • withOutputDirectory

      public abstract Filetransfer withOutputDirectory(File outputDir)
      Sets the output directory where received files are stored. This has only effect by using withOriginalFilename(true)
      Parameters:
      outputDir - Output directory
      Returns:
      this Filetransfer object
    • withOriginalFilename

      public abstract Filetransfer withOriginalFilename(boolean withOriginalFilename)
      Enables/disables the use of the original filenames of the receiving files. Default is true. Requires to set the output directory.
      Parameters:
      withOriginalFilename - true/false
      Returns:
      this Filetransfer object
    • withLink

      public abstract Filetransfer withLink(String link)
      Sets the link of a file to receive.
      Parameters:
      link - link to a file
      Returns:
      this Filetransfer object
    • withDigestType

      public abstract Filetransfer withDigestType(String digestType)
      Sets the type of the digest that is used to verify the consistency of the file transfer.

      The digest type must be one of the availables types of the platform. The sender defines this type for a file and the receiver of the file must use the same type. Default is "MD5".

      Parameters:
      digestType - type of the message digest
      Returns:
      this Filetransfer object
    • withDeleteAfterNumberDownloads

      public abstract Filetransfer withDeleteAfterNumberDownloads(int deleteAfterNumberDownloads)
      The sender can define a maximum number of downloads for a file. The file will be automatically deleted when this number is reached. Default is unlimited downloads so the files needs to be deleted explicitely.
      Parameters:
      deleteAfterNumberDownloads - max number of downloads
      Returns:
      this Filetransfer object
    • withPassword

      public abstract Filetransfer withPassword(String password)
      Sets the password for a file. During send this method defines the password, during receive this method specifies it. Passwords are not being transferred as clear text, instead a hash is used.
      Parameters:
      password - the password
      Returns:
      this Filetransfer object
    • withPasswordHexDigest

      public abstract Filetransfer withPasswordHexDigest(String passwordHexDigest)
      For internal use only!
      Parameters:
      passwordHexDigest - the password hex digest
      Returns:
      this Filetransfer object
    • withExpiration

      public abstract Filetransfer withExpiration(long expiration)
      The sender can define an expiration time in millisecond relative to the time when the file is store at the file cache. So if the file is stored at 13:45:10 and the expiration is set to 60000 (1 minute), the file expires at 13:46:10. Expired files will be automatically deleted from the file cache. Default is no expiration.
      Parameters:
      expiration - expiration time in milliseconds.
      Returns:
      this Filetransfer object
    • withFileIsPrivate

      public abstract Filetransfer withFileIsPrivate(boolean fileIsPrivate)
      A sender can declare a file as private. Private files are not returned by a query, rather the link to that file must be passed from the sender to the receiver (e.g. by using JMS). Default is false.
      Parameters:
      fileIsPrivate - true/false
      Returns:
      this Filetransfer object
    • withProperties

      public abstract Filetransfer withProperties(Map<String,Object> properties)
      A sender can add any custom properties to a file. The names and types of the properties have to adhere to the JMS standard (message.setObject(name, value) must succeed for each property).
      Parameters:
      properties - Map with properties
      Returns:
      this Filetransfer object
    • withSelector

      public abstract Filetransfer withSelector(String selector)
      Sets a JMS message selector to use by a query.
      Parameters:
      selector - JMS message selector
      Returns:
      this Filetransfer object
    • withReplyInterval

      public abstract Filetransfer withReplyInterval(int replyInterval)
      Sets the internal message transfer interval in which a consistency check is performed. Default is 10.
      Parameters:
      replyInterval - reply interval
      Returns:
      this Filetransfer object
    • send

      public abstract String send(ProgressListener progressListener) throws Exception
      Performs the sending file transfer and notifies a progress listener during the transfer.
      Parameters:
      progressListener - progress listener
      Returns:
      link to the file
      Throws:
      Exception - if anything goes wrong
    • send

      public abstract String send() throws Exception
      Performs the sending file transfer.
      Returns:
      link to the file
      Throws:
      Exception - if anything goes wrong
    • receive

      public abstract Filetransfer receive(ProgressListener progressListener) throws Exception
      Performs the receiving file transfer and notifies a progress listener during the transfer.
      Parameters:
      progressListener - progress listener
      Returns:
      this Filetransfer object
      Throws:
      Exception - if anything goes wrong
    • receive

      public abstract Filetransfer receive() throws Exception
      Performs the receiving file transfer.
      Returns:
      this Filetransfer object
      Throws:
      Exception - if anything goes wrong
    • delete

      public abstract Filetransfer delete() throws Exception
      Deletes a file. Requires that the link has been set. Usually called after receive()
      Returns:
      this Filetransfer object
      Throws:
      Exception - if anything goes wrong
    • query

      public abstract List<String> query() throws Exception
      Queries the file cache and returns a list of links. If the selector is set, it is applied, otherwise the links to all files of the cache are returned. Links to private files are never returned.
      Returns:
      result
      Throws:
      Exception - if anything goes wrong
    • queryProperties

      public abstract Map<String,Map<String,Object>> queryProperties() throws Exception
      Queries the file cache and returns a map where the key is the link and the value is another Map with all properties of that file. If the selector is set, it is applied. If a link is set, only the properties of that link are returned, otherwise the links/properties of all files of the cache are returned. Properties of private files are never returned.
      Returns:
      result
      Throws:
      Exception - if anything goes wrong
    • close

      public abstract void close()
      Closes this Filetransfer object and releases all resources (e.g. the internal JMS session)