de.unido.ls5.eti.client
Class TransferHandler

java.lang.Object
  extended by de.unido.ls5.eti.client.TransferHandler

public class TransferHandler
extends Object

This class manages the jETI file context. It keeps track where the most recently modified version of a filename can be found. and stores/retrieves/forwards them the the required location if necessary.

Rating red

Field Summary
static String CONTEXT_ETI_CONNECTIONS
          context key name where the EtiConnection Map is stored.
static String CONTEXT_TRANSFER_HANDLER
          Context key name where the TransferHandler is stored.
 
Method Summary
 void closeAllSessions()
           
static TransferHandler get(Map<String,Object> env)
          Retrieves the TransferHandler from given ExecutionEnvironment.
 VirtualFile get(String name)
          Retrieves the VirtualFile Object from the Context.
 EtiConnection getEtiConnection(List<URI> uris)
          Retrieve an ETI Connection for a given List of uris following the order of the list.
 EtiConnection getEtiConnection(URI uri, boolean createNew)
          Looks up the internal LightweightExecutionEnvironment wether there already exists a connection to the jETI toolserver identified by uri.
static boolean isDebug()
           
 void put(VirtualFile vFile, String name)
          put virtual file into executionEnvironment and set cache entry for name to local URI
 void setCurrentLocation(List<String> names, URI uri)
           
 void setCurrentLocation(String[] names, URI uri)
          This method can be used to tell the transfher handler, that the most recently modified version of given filenames can now be found at uri.
static void setDebug(boolean debug)
           
 void storeToLocation(List<String> names, URI targetServer)
           
 void storeToLocation(String[] names, URI targetServer)
          Makes sure that the newest version of all files provided by parameter 'names' is located at the given URI afterwards.
 String toString()
          Generates a String representation of this transfher handler that contains debug information such as number of known files and number of files in local context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTEXT_ETI_CONNECTIONS

public static final String CONTEXT_ETI_CONNECTIONS
context key name where the EtiConnection Map is stored. Only used in debug mode

See Also:
Constant Field Values

CONTEXT_TRANSFER_HANDLER

public static final String CONTEXT_TRANSFER_HANDLER
Context key name where the TransferHandler is stored.

See Also:
Constant Field Values
Method Detail

get

public static TransferHandler get(Map<String,Object> env)
Retrieves the TransferHandler from given ExecutionEnvironment. If env does not yet contain a TransferHandler, a new one is instanciated, put into env and returned.

Parameters:
env - the given execution environment
Returns:
the transfher handler from env or a newly instanciated one
Throws:
ClassCastException - if the environment contains an Object with key CONTEXT_TRANSFER_HANDLER that cannot be casted to TransfherHandler

getEtiConnection

public EtiConnection getEtiConnection(URI uri,
                                      boolean createNew)
                               throws EtiLocalException,
                                      EtiRemoteException
Looks up the internal LightweightExecutionEnvironment wether there already exists a connection to the jETI toolserver identified by uri. If a connection exists, it is returned. If not, a new one is instanciated or null is returned (depends on createNew) (EtiConnectionFactory.createConnection(URI) is used to create new connection)

Parameters:
uri - URI of the jETI toolserver
createNew - defines wether a new EtiConnection should be instanciated if there's none found
Returns:
connection to server or null, if createNew == false and no connection was found
Throws:
EtiLocalException - if the URI is not valid for jETI connections
EtiRemoteException - if login to server failed

getEtiConnection

public EtiConnection getEtiConnection(List<URI> uris)
                               throws EtiLocalException
Retrieve an ETI Connection for a given List of uris following the order of the list. It first tries to find an already existing connection according to the list. if none is found, it iterates the list again trying to create new a connection object. This method will always return a valid connection or throw an Exception if it fails.

Parameters:
uris -
Returns:
the EtiConnection
Throws:
EtiLocalException

put

public void put(VirtualFile vFile,
                String name)
put virtual file into executionEnvironment and set cache entry for name to local URI

Parameters:
vFile -
name -

get

public VirtualFile get(String name)
                throws EtiLocalException,
                       EtiRemoteException
Retrieves the VirtualFile Object from the Context. If the File is still located at the Server, it will be retrieved first.

Parameters:
name -
Returns:
The requested VirtualFile or null, if there is no known location for that file
Throws:
EtiLocalException
EtiRemoteException

setCurrentLocation

public void setCurrentLocation(List<String> names,
                               URI uri)

setCurrentLocation

public void setCurrentLocation(String[] names,
                               URI uri)
This method can be used to tell the transfher handler, that the most recently modified version of given filenames can now be found at uri. This should only be used for newly created files in remote contexts (e.g. OutputParameters of tools).

Parameters:
names -
uri -

storeToLocation

public void storeToLocation(List<String> names,
                            URI targetServer)
                     throws EtiLocalException,
                            EtiRemoteException
Throws:
EtiLocalException
EtiRemoteException

storeToLocation

public void storeToLocation(String[] names,
                            URI targetServer)
                     throws EtiLocalException,
                            EtiRemoteException
Makes sure that the newest version of all files provided by parameter 'names' is located at the given URI afterwards. If the newest file is already located at that server, no transfer will be made.

Parameters:
names - array of filenames from the jETI context
targetServer - the URI of the server where the newest versions of names are needed.
Throws:
EtiLocalException - if names contains an unknown filename
EtiRemoteException - if store or forward somehow fails

closeAllSessions

public void closeAllSessions()

toString

public String toString()
Generates a String representation of this transfher handler that contains debug information such as number of known files and number of files in local context.

Overrides:
toString in class Object
Returns:
the string representation of this transfer handler

isDebug

public static boolean isDebug()

setDebug

public static void setDebug(boolean debug)