org.neociclo.odetteftp.support
Class OftpletEventListenerAdapter

java.lang.Object
  extended by org.neociclo.odetteftp.support.OftpletEventListenerAdapter
All Implemented Interfaces:
EventListener, OftpletListener, OftpletSpeaker, OftpletEventListener

public class OftpletEventListenerAdapter
extends Object
implements OftpletEventListener

Version:
$Rev: 805 $ $Date: 2010-10-20 11:14:54 -0200 (Wed, 20 Oct 2010) $
Author:
Rafael Marins

Constructor Summary
OftpletEventListenerAdapter()
           
 
Method Summary
 StartFileResponse acceptStartFile(VirtualFile virtualFile)
          Callback method indicating a receive file request, used to construct and return the VirtualFile instance.
 void configure(OdetteFtpSession session)
           
 void destroy()
           
 void init(OdetteFtpSession session)
           
 OdetteFtpObject nextOftpObjectToSend()
           
 void onDataReceived(VirtualFile virtualFile, long totalOctetsReceived)
           
 void onDataSent(VirtualFile virtualFile, long totalOctetsSent)
           
 void onExceptionCaught(Throwable cause)
           
 void onNotificationReceived(DeliveryNotification notif)
          Callback method to indicate the Oftplet about the receive of a delivery notification.
 void onNotificationSent(DeliveryNotification notif)
           
 EndFileResponse onReceiveFileEnd(VirtualFile virtualFile, long recordCount, long unitCount)
          Callback method indicating the file receive end request with given parameters information used to check the integrity of the received file.
 void onReceiveFileError(VirtualFile virtualFile, AnswerReasonInfo reason)
           
 void onReceiveFileStart(VirtualFile virtualFile, long answerCount)
           
 void onSendFileEnd(VirtualFile virtualFile)
          Callback method invoked when the file is fully transmitted.
 void onSendFileError(VirtualFile virtualFile, AnswerReasonInfo reason, boolean retryLater)
          Callback method to indicate the transmitting file is not accepted by the other peer - being in the Speaker state.
 void onSendFileStart(VirtualFile virtualFile, long answerCount)
          Callback method to indicate the given file transfer will begin.
 void onSessionEnd()
           
 void onSessionStart()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OftpletEventListenerAdapter

public OftpletEventListenerAdapter()
Method Detail

nextOftpObjectToSend

public OdetteFtpObject nextOftpObjectToSend()
Specified by:
nextOftpObjectToSend in interface OftpletSpeaker

onDataSent

public void onDataSent(VirtualFile virtualFile,
                       long totalOctetsSent)
Specified by:
onDataSent in interface OftpletSpeaker

onNotificationSent

public void onNotificationSent(DeliveryNotification notif)
Specified by:
onNotificationSent in interface OftpletSpeaker

onSendFileEnd

public void onSendFileEnd(VirtualFile virtualFile)
Description copied from interface: OftpletSpeaker
Callback method invoked when the file is fully transmitted. It happens after receiving the End File Positive Answer (EFNA) command while in the Speaker state.

Specified by:
onSendFileEnd in interface OftpletSpeaker

onSendFileError

public void onSendFileError(VirtualFile virtualFile,
                            AnswerReasonInfo reason,
                            boolean retryLater)
Description copied from interface: OftpletSpeaker
Callback method to indicate the transmitting file is not accepted by the other peer - being in the Speaker state. It is always the case when receiving a Start File Negative Answer (SFNA) and End File Negative Answer (EFNA) protocol commands.

Any other kind of error, such as IoException or FileTransferException, it should be handled by the Oftplet.onExceptionCaught(Throwable) method.

Specified by:
onSendFileError in interface OftpletSpeaker

onSendFileStart

public void onSendFileStart(VirtualFile virtualFile,
                            long answerCount)
Description copied from interface: OftpletSpeaker
Callback method to indicate the given file transfer will begin. Called after the receive of Start File Positive Answer (SFPA) command while in the Speaker state, just before the first DATA command is released.

Specified by:
onSendFileStart in interface OftpletSpeaker
Parameters:
virtualFile - the bundle of transfer info and virtual file being transferred.
answerCount - negotiated restart offset

acceptStartFile

public StartFileResponse acceptStartFile(VirtualFile virtualFile)
Description copied from interface: OftpletListener
Callback method indicating a receive file request, used to construct and return the VirtualFile instance. Returning null corresponds to refuse the file receiving - reply with Start File Negative Answer (SFNA) with AnswerReason.UNSPECIFIED reason.

The given parameters provide required information to map the transferring VirtualFile into the Oftplet implementation's local system.

Specified by:
acceptStartFile in interface OftpletListener
Parameters:
virtualFile - holder of file receive indication parameters.
Returns:
the VirtualFile instance ready to start the file receiving.

onDataReceived

public void onDataReceived(VirtualFile virtualFile,
                           long totalOctetsReceived)
Specified by:
onDataReceived in interface OftpletListener

onNotificationReceived

public void onNotificationReceived(DeliveryNotification notif)
Description copied from interface: OftpletListener
Callback method to indicate the Oftplet about the receive of a delivery notification. Called when processing the receive of the End-to-End Response (EERP) or Negative End Response (NERP) command while in the Listener state.

Specified by:
onNotificationReceived in interface OftpletListener
Parameters:
notif - holder of the received delivery notification parameters.

onReceiveFileEnd

public EndFileResponse onReceiveFileEnd(VirtualFile virtualFile,
                                        long recordCount,
                                        long unitCount)
Description copied from interface: OftpletListener
Callback method indicating the file receive end request with given parameters information used to check the integrity of the received file. When an inconsistency is found this method should throw a FileTransferException with the proper reason code.

The returning boolean value indicates whether the other peer, operating in the Speaker state, should issue a Change Direction (CD) command and revert this Oftplet implementation ODETTE-FTP entity state.

Specified by:
onReceiveFileEnd in interface OftpletListener
recordCount - number of records the other ODETTE-FTP peer sent in the VirtualFile.
unitCount - exact number of units (octets) transmitted.
Returns:
whether to change direction after complete the file receiving.

onReceiveFileError

public void onReceiveFileError(VirtualFile virtualFile,
                               AnswerReasonInfo reason)
Specified by:
onReceiveFileError in interface OftpletListener

onReceiveFileStart

public void onReceiveFileStart(VirtualFile virtualFile,
                               long answerCount)
Specified by:
onReceiveFileStart in interface OftpletListener

onExceptionCaught

public void onExceptionCaught(Throwable cause)
Specified by:
onExceptionCaught in interface OftpletEventListener

onSessionStart

public void onSessionStart()
Specified by:
onSessionStart in interface OftpletEventListener

onSessionEnd

public void onSessionEnd()
Specified by:
onSessionEnd in interface OftpletEventListener

destroy

public void destroy()
Specified by:
destroy in interface OftpletEventListener

init

public void init(OdetteFtpSession session)
          throws OdetteFtpException
Specified by:
init in interface OftpletEventListener
Throws:
OdetteFtpException

configure

public void configure(OdetteFtpSession session)
Specified by:
configure in interface OftpletEventListener


ACCORD