Lightweight Bartering Grid

lbg.protocol.data
Class FTPGridData

java.lang.Object
  extended by lbg.protocol.data.GridData
      extended by lbg.protocol.data.FTPGridData
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<GridData>

public class FTPGridData
extends GridData

Keep info to find a file that lies on an FTP

Author:
Xavier Dalem
See Also:
Serialized Form

Field Summary
 
Fields inherited from class lbg.protocol.data.GridData
client_hostname, HASHING_ALGORITHM, id, size
 
Constructor Summary
FTPGridData(java.lang.String id, long size, java.lang.String host, int port, java.lang.String path, java.lang.String user, java.lang.String password, byte[] checksum)
          Makes a new FTPGridData.
 
Method Summary
 byte[] getChecksum()
          Get checksum from data.
 java.io.InputStream getInputStream()
          Get an input stream to read the data
 void setLocalParameters(java.lang.String hostname, int port)
           
 void toFile(java.io.File file)
          Save data in a file.
 
Methods inherited from class lbg.protocol.data.GridData
compareTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FTPGridData

public FTPGridData(java.lang.String id,
                   long size,
                   java.lang.String host,
                   int port,
                   java.lang.String path,
                   java.lang.String user,
                   java.lang.String password,
                   byte[] checksum)
            throws GridException
Makes a new FTPGridData.

Parameters:
id - The unique ID for the file. It should be of the form requestingpeerID.userID.filename
path - Absolute path for data on the FTP server
host - The host where data lies.
port - The port on the FTP server.
user - Login on FTP server.
password - Associated password to user.
checksum - Checksum of the given data
Throws:
GridException - if parameters are invalid.
Method Detail

setLocalParameters

public void setLocalParameters(java.lang.String hostname,
                               int port)
                        throws GridException
Throws:
GridException

toFile

public void toFile(java.io.File file)
            throws GridException
Save data in a file. This call is blocking.

FTP transfer is in passive mode, you don't need to worry about ports to open.

Specified by:
toFile in class GridData
Parameters:
file - The file where to put data
Throws:
GridException

getChecksum

public byte[] getChecksum()
                   throws GridException
Description copied from class: GridData
Get checksum from data. It must be the checksum from the real data, not of data and combined details like it is the case for torrents.
The used algorithm is specified by HASHING_ALGORITHM.

Specified by:
getChecksum in class GridData
Throws:
GridException
See Also:
GridData.HASHING_ALGORITHM

getInputStream

public java.io.InputStream getInputStream()
                                   throws GridException
Description copied from class: GridData
Get an input stream to read the data

Specified by:
getInputStream in class GridData
Throws:
GridException - If the file doesn't exist

Lightweight Bartering Grid

Copyright (c) 2005-2008, Cyril Briquet, parts Xavier Dalem.