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

java.lang.Object
  extended by org.apache.oodt.cas.pushpull.protocol.Protocol
Direct Known Subclasses:
CogJGlobusFtpClient, CommonsNetFtpClient, HttpClient, ImapsClient, JschSftpClient, LocalClient

public abstract class Protocol
extends Object

Version:
$Revision$

Protocol Interface Class

.
Author:
bfoster

Field Summary
protected  String protocolType
           
protected  RemoteSite remoteSite
           
 
Constructor Summary
protected Protocol(String protocolType)
           
 
Method Summary
abstract  void abortCurFileTransfer()
           
 void cd(ProtocolFile file)
          Changes directories to the given directory passed in (insures that the correct path goes to the cd(String) method implemented by inheriting classes
 void cdToHOME()
           
protected abstract  void cdToRoot()
           
 void cdToROOT()
           
protected abstract  void chDir(ProtocolPath path)
           
 void connect(RemoteSite remoteSite)
          Connects the Protocol to the given server
protected abstract  void connect(String host, String username, String password)
           
 boolean delete(ProtocolFile file)
           
protected abstract  boolean deleteFile(ProtocolFile file)
           
 void disconnect()
           
protected abstract  void disconnectFromServer()
          Disconnects the Protocol for the server
 void download(ProtocolFile file, File toLocalFile)
           
 void download(ProtocolFile file, File toLocalFile, long timeout)
           
 boolean equals(Object protocol)
          Overrides the Object class equals method.
protected  String getAbsPathFor(String path)
           
protected abstract  ProtocolFile getCurrentWorkingDir()
          Returns a string value of current directory -- similar to U*ix pwd()
protected abstract  void getFile(ProtocolFile file, File toLocalFile)
          Downloads a file from Protocol server to the location specified by the java.io.File passed in.
 ProtocolFile getHomeDir()
           
 ProtocolFile getProtocolFileFor(String file, boolean isDir)
           
 String getProtocolType()
           
 RemoteSite getRemoteSite()
          The name of the Protocol server host name
protected abstract  boolean isConnected()
          Can be used to determine if Protocol is connected
 boolean isProtocolConnected()
           
protected abstract  List<ProtocolFile> listFiles()
           
 List<ProtocolFile> ls()
           
 List<ProtocolFile> ls(ProtocolFile dir)
           
 List<ProtocolFile> ls(ProtocolFileFilter filter)
           
 ProtocolFile pwd()
           
protected  void reconnect()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

protocolType

protected String protocolType

remoteSite

protected RemoteSite remoteSite
Constructor Detail

Protocol

protected Protocol(String protocolType)
Method Detail

chDir

protected abstract void chDir(ProtocolPath path)
                       throws ProtocolException
Throws:
ProtocolException

cdToRoot

protected abstract void cdToRoot()
                          throws ProtocolException
Throws:
ProtocolException

connect

protected abstract void connect(String host,
                                String username,
                                String password)
                         throws ProtocolException
Throws:
ProtocolException

disconnectFromServer

protected abstract void disconnectFromServer()
                                      throws ProtocolException
Disconnects the Protocol for the server

Throws:
IOException - If error is encountered while disconnecting
ProtocolException

isConnected

protected abstract boolean isConnected()
                                throws ProtocolException
Can be used to determine if Protocol is connected

Returns:
true if Protocol is connected, otherwise false
Throws:
ProtocolException

getFile

protected abstract void getFile(ProtocolFile file,
                                File toLocalFile)
                         throws ProtocolException
Downloads a file from Protocol server to the location specified by the java.io.File passed in. Only a name can be passed in for fileName, can't be a path. User must first navigate to the directory which contains the file and then can call this method.

Parameters:
fileName - The name of the file at Protocol server
localFileLocation - The name and location that file should be stored
Throws:
RemoteCommunicationException - If an error is encountered while downloading file
ProtocolException

abortCurFileTransfer

public abstract void abortCurFileTransfer()
                                   throws ProtocolException
Throws:
ProtocolException

getCurrentWorkingDir

protected abstract ProtocolFile getCurrentWorkingDir()
                                              throws ProtocolException
Returns a string value of current directory -- similar to U*ix pwd()

Returns:
The path of current directory
Throws:
RemoteCommunicationException - If an error is encountered while retreiving path
ProtocolException

listFiles

protected abstract List<ProtocolFile> listFiles()
                                         throws ProtocolException
Throws:
ProtocolException

deleteFile

protected abstract boolean deleteFile(ProtocolFile file)

connect

public void connect(RemoteSite remoteSite)
             throws ProtocolException
Connects the Protocol to the given server

Parameters:
server - The URL to which the Protocol will be connected
Throws:
RemoteConnectionException - If error is encountered while connecting to server
ProtocolException

reconnect

protected void reconnect()
                  throws ProtocolException
Throws:
ProtocolException

isProtocolConnected

public boolean isProtocolConnected()
                            throws ProtocolException
Throws:
ProtocolException

disconnect

public void disconnect()
                throws ProtocolException
Throws:
ProtocolException

cd

public void cd(ProtocolFile file)
        throws ProtocolException
Changes directories to the given directory passed in (insures that the correct path goes to the cd(String) method implemented by inheriting classes

Parameters:
dir - The path of directory to change to, can be relative or absolute
Throws:
RemoteCommunicationException
ProtocolException

cdToHOME

public void cdToHOME()
              throws ProtocolException
Throws:
ProtocolException

cdToROOT

public void cdToROOT()
              throws ProtocolException
Throws:
ProtocolException

getProtocolFileFor

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

equals

public boolean equals(Object protocol)
Overrides the Object class equals method.

Overrides:
equals in class Object
Parameters:
protocol - The comparing protocol
Returns:
true if the two protocols are equal

download

public void download(ProtocolFile file,
                     File toLocalFile)
              throws ProtocolException
Throws:
ProtocolException

download

public void download(ProtocolFile file,
                     File toLocalFile,
                     long timeout)
              throws ProtocolException
Throws:
ProtocolException

delete

public boolean delete(ProtocolFile file)

pwd

public ProtocolFile pwd()
                 throws ProtocolException
Throws:
ProtocolException

ls

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

ls

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

ls

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

getProtocolType

public String getProtocolType()
Returns:
String The type of protocol

getRemoteSite

public RemoteSite getRemoteSite()
The name of the Protocol server host name

Returns:
The name of server host

getHomeDir

public ProtocolFile getHomeDir()

getAbsPathFor

protected String getAbsPathFor(String path)


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