org.apache.oodt.cas.pushpull.protocol
Class ProtocolHandler

java.lang.Object
  extended by org.apache.oodt.cas.pushpull.protocol.ProtocolHandler

public class ProtocolHandler
extends Object

This class is responsible for creating the appropriate Protocol for the given RemoteSites. The boolean argument 'allowReuse' allows for one unique protocol for each URL. That is, if allowReuse is set to true, then if no Protocol has been created for the current site, the Protocol created will be saved and then returned for any later called with allowReuse equals true. This is to allow for the same Protocol object to be used by several classes. The Protocol class has been synchronized so this is thread-safe. If you set 'allowReuse' to false then a new Protocol object will be created and returned.

Author:
bfoster

Constructor Summary
ProtocolHandler(ProtocolInfo pi)
          Creates a new ProtocolHandler for the given Config object
 
Method Summary
 void cd(Protocol protocol, ProtocolFile file)
           
 void cdToHOME(Protocol protocol)
           
 void cdToROOT(Protocol protocol)
           
 void close()
          Disconnects all waiting Protocols and clears the waiting lists.
 boolean connect(Protocol protocol, RemoteSite remoteSite, boolean test)
          Connects the given Protocol to the given URL
 boolean delete(Protocol protocol, ProtocolFile file)
           
 void disconnect(Protocol protocol)
          Disconnects and logs out the given Protocol
 void download(Protocol protocol, ProtocolFile fromFile, File toFile, boolean delete)
           
 String getAbsPathFor(Protocol protocol, String path)
           
 Protocol getAppropriateProtocol(ProtocolFile pFile, boolean allowReuse, boolean navigateToPathLoc)
          Returns the appropriate protocol for the given Path
 Protocol getAppropriateProtocolBySite(RemoteSite remoteSite, boolean allowReuse)
           
 ProtocolFile getHomeDir(Protocol protocol)
           
 ProtocolFile getProtocolFileFor(Protocol protocol, String file, boolean isDir)
           
 String getProtocolType(Protocol protocol)
           
 RemoteSite getRemoteSite(Protocol protocol)
           
 boolean isProtocolConnected(Protocol protocol)
           
 List<ProtocolFile> ls(Protocol protocol)
           
 List<ProtocolFile> ls(Protocol protocol, ProtocolFile dir)
           
 List<ProtocolFile> ls(Protocol protocol, ProtocolFileFilter filter)
           
 List<ProtocolFile> nextPage(Protocol protocol)
           
 List<ProtocolFile> nextPage(Protocol protocol, ProtocolFileFilter filter)
           
 ProtocolFile pwd(Protocol protocol)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProtocolHandler

public ProtocolHandler(ProtocolInfo pi)
Creates a new ProtocolHandler for the given Config object

Parameters:
config - The Config object that guides this ProtocolHandler in making class instanciations
Method Detail

getAppropriateProtocol

public Protocol getAppropriateProtocol(ProtocolFile pFile,
                                       boolean allowReuse,
                                       boolean navigateToPathLoc)
                                throws RemoteConnectionException
Returns the appropriate protocol for the given Path

Parameters:
ProtocolPath - Used to determine the appropriate Protocol to be returned and the path to navigate on if navigateToPathLoc is set to true.
allowReuse - Set to true if you would like ProtocolHandler to take care of the protocol returned (i.e. reuseable protocols may be returned by this method again, if it is the appropriate protocol type for a given Path. Also ProtocolHandler will take care of disconnecting the reuseable protocols)
navigateToPathLoc - If true, will navigate the to the end of the Path location specified
Returns:
Protocol for the given Path
Throws:
RemoteCommunicationException - If there is an error creating the protocol
RemoteConnectionException

getAppropriateProtocolBySite

public Protocol getAppropriateProtocolBySite(RemoteSite remoteSite,
                                             boolean allowReuse)
                                      throws ProtocolException
Throws:
ProtocolException

nextPage

public List<ProtocolFile> nextPage(Protocol protocol)
                            throws RemoteConnectionException,
                                   ProtocolException
Throws:
RemoteConnectionException
ProtocolException

nextPage

public List<ProtocolFile> nextPage(Protocol protocol,
                                   ProtocolFileFilter filter)
                            throws RemoteConnectionException,
                                   ProtocolException
Parameters:
protocol -
Returns:
Throws:
RemoteConnectionException
ProtocolException

download

public void download(Protocol protocol,
                     ProtocolFile fromFile,
                     File toFile,
                     boolean delete)
              throws RemoteConnectionException
Throws:
RemoteConnectionException

connect

public boolean connect(Protocol protocol,
                       RemoteSite remoteSite,
                       boolean test)
Connects the given Protocol to the given URL

Parameters:
protocol - The Protocol that will be connected
url - The server to which the Protocol will connect
Throws:
RemoteConnectionException - If connection fails
RemoteLoginException - If login fails

cdToROOT

public void cdToROOT(Protocol protocol)
              throws ProtocolException
Throws:
ProtocolException

cdToHOME

public void cdToHOME(Protocol protocol)
              throws ProtocolException
Throws:
ProtocolException

isProtocolConnected

public boolean isProtocolConnected(Protocol protocol)
                            throws ProtocolException
Throws:
ProtocolException

cd

public void cd(Protocol protocol,
               ProtocolFile file)
        throws ProtocolException
Throws:
ProtocolException

getProtocolFileFor

public ProtocolFile getProtocolFileFor(Protocol protocol,
                                       String file,
                                       boolean isDir)
                                throws ProtocolException
Throws:
ProtocolException

delete

public boolean delete(Protocol protocol,
                      ProtocolFile file)
               throws MalformedURLException,
                      ProtocolException
Throws:
MalformedURLException
ProtocolException

pwd

public ProtocolFile pwd(Protocol protocol)
                 throws ProtocolException
Throws:
ProtocolException

ls

public List<ProtocolFile> ls(Protocol protocol,
                             ProtocolFile dir)
                      throws ProtocolException
Throws:
ProtocolException

ls

public List<ProtocolFile> ls(Protocol protocol)
                      throws ProtocolException
Throws:
ProtocolException

ls

public List<ProtocolFile> ls(Protocol protocol,
                             ProtocolFileFilter filter)
                      throws ProtocolException
Throws:
ProtocolException

getProtocolType

public String getProtocolType(Protocol protocol)

getRemoteSite

public RemoteSite getRemoteSite(Protocol protocol)

getHomeDir

public ProtocolFile getHomeDir(Protocol protocol)

getAbsPathFor

public String getAbsPathFor(Protocol protocol,
                            String path)

disconnect

public void disconnect(Protocol protocol)
                throws RemoteConnectionException
Disconnects and logs out the given Protocol

Parameters:
protocol - The Protocol to be logout out and disconnected
Throws:
RemoteConnectionException

close

public void close()
           throws RemoteConnectionException
Disconnects all waiting Protocols and clears the waiting lists. Also clears the current Protocol

Throws:
RemoteConnectionException


Copyright © 1999-2011 Apache OODT. All Rights Reserved.