org.fossilec.odettej.service
Class CommandExchangeBuffer

java.lang.Object
  extended by org.fossilec.odettej.service.OdetteExchangeBuffer
      extended by org.fossilec.odettej.service.CommandExchangeBuffer

public class CommandExchangeBuffer
extends OdetteExchangeBuffer

A Command Exchange Buffer contains a single command starting at the beginning of the buffer. Commands and data are never mixed within an Exchange Buffer. Each command has a fixed length and can not be compressed.


Field Summary
 
Fields inherited from class org.fossilec.odettej.service.OdetteExchangeBuffer
buffer, BUFFER_CHARSET, MAX_OEB_LENGTH, MIN_OEB_LENGTH
 
Constructor Summary
protected CommandExchangeBuffer(java.nio.ByteBuffer rawBuffer, boolean strictFormat)
           
 
Method Summary
static CommandExchangeBuffer changeDirection()
          Create the Change Direction command.
static CommandExchangeBuffer endFile(int recordCount, long unitCount)
          Create the End File command indicating the count of records and overall octets from the transmitted Virtual File.
The count will express the real size of the file (before compression, header not included).
static CommandExchangeBuffer endFileNegativeAnswer(AnswerReason reason)
          Create the End File Negative Answer command providing the reason for stopping transfer.
static CommandExchangeBuffer endFilePositiveAnswer(boolean changeDirection)
          Create the End File Positive Answer command indicating whether the Listener is requesting or not a Change Direction (CD) command from Speaker or not.
static CommandExchangeBuffer endSession(EndSessionReason reason)
          Create the End Session command indicating the reason code for terminating the session.
static CommandExchangeBuffer endToEndResponse(java.lang.String dataSetName, java.lang.String reserved, java.util.Date dateTime, java.lang.String userData, java.lang.String destination, java.lang.String originator)
          Create the End to End Response command with given parameters.
 java.lang.String getParameter(java.lang.String name)
          Return a Command Exchange Buffer parameter value for the specified field.
 java.util.Collection getParameters()
           
protected  void parse(java.nio.ByteBuffer rawBuffer)
          Method used to set configure this object with the value from parsing the given raw buffer.
static CommandExchangeBuffer readyMessage()
          Start Session Ready Message.
static CommandExchangeBuffer readyToReceive()
          Create the Ready to Receive command.
static CommandExchangeBuffer setCredit(java.lang.String reserved)
          Create the Set Credit command which is used to avoid congestion at the protocol level a flow control.
protected  void setParamater(java.lang.String name, java.lang.String value)
          Set a parameter in command stream with the given value.
static CommandExchangeBuffer startFile(java.lang.String datasetName, java.lang.String reserved, java.util.Date dateTime, java.lang.String userData, java.lang.String destination, java.lang.String originator, RecordFormat recordFormat, int maxRecordSize, int fileSize, int restartOffset)
          Create the Start File command with given parameters.
The Start File command includes a count allowing the restart of an interrupted transmission to be negotiated.
static CommandExchangeBuffer startFileNegativeAnswer(AnswerReason reason, boolean retry)
          Create the Start File Negative Answer command containing the the reason why transmission can not proced.
This retry parameter is used to advise the Speaker if it should retry at a latter point in time due to a temporary condition at the Listener site, such as a lack of storage space.
static CommandExchangeBuffer startFilePositiveAnswer(int answerCount)
          Create the Start File Positive Answer command.
static CommandExchangeBuffer startSession(java.lang.String code, java.lang.String pswd, int sdeb, TransferMode mode, boolean compression, boolean restart, boolean specialLogic, int credit, java.lang.String reserved, java.lang.String userData)
          Create the Start Session command with given parameters.
 
Methods inherited from class org.fossilec.odettej.service.OdetteExchangeBuffer
getBuffer, getIdentifier, getInstance, getLength, setBuffer, setIdentifier, setLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandExchangeBuffer

protected CommandExchangeBuffer(java.nio.ByteBuffer rawBuffer,
                                boolean strictFormat)
                         throws OdetteFTPException
Throws:
OdetteFTPException
Method Detail

readyMessage

public static CommandExchangeBuffer readyMessage()
                                          throws OdetteFTPException
Start Session Ready Message.

Returns:
Corresponding CommandExchangeBuffer.
Throws:
OdetteFTPException

startSession

public static CommandExchangeBuffer startSession(java.lang.String code,
                                                 java.lang.String pswd,
                                                 int sdeb,
                                                 TransferMode mode,
                                                 boolean compression,
                                                 boolean restart,
                                                 boolean specialLogic,
                                                 int credit,
                                                 java.lang.String reserved,
                                                 java.lang.String userData)
                                          throws OdetteFTPException
Create the Start Session command with given parameters. It belongs to the Start Session Phase, and is performed in both direction to negotiate capabilities and session wide parameters between locations.

Parameters:
code - Initiator's Identification Code which uniquely identifies the Initiator (sender) participating in the Odette FTP session.
pswd - Key to authenticate the sender. Assigned by bilateral agreement.
sdeb - The length, in octets, of the largest Exchange Buffer that can be accepted by the location.
sendReceive - Sender / Receiver capabilities:
compression - Compression indicator. true if the location can handle compressed data. Otherwise it should be false.
restart - Restart indication informing whether the location can handle the restart of a partially transmitted file.
specialLogic - Special logic indication.
credit - Credit.
reserved - Reserved for future use.
userData - User Data.
Returns:
The Start Session command with the corresponding values.
Throws:
OdetteFTPException

startFile

public static CommandExchangeBuffer startFile(java.lang.String datasetName,
                                              java.lang.String reserved,
                                              java.util.Date dateTime,
                                              java.lang.String userData,
                                              java.lang.String destination,
                                              java.lang.String originator,
                                              RecordFormat recordFormat,
                                              int maxRecordSize,
                                              int fileSize,
                                              int restartOffset)
                                       throws OdetteFTPException
Create the Start File command with given parameters.
The Start File command includes a count allowing the restart of an interrupted transmission to be negotiated. If restart facilities are not available the restart count must be set to zero. The sender will start with the lowest record count + 1.

Parameters:
datasetName - Dataset name of the Virtual File being transferred assigned by bilateral agreement.
reserved - This field is reserved for future use.
dateTime - Specific Date and Time assigned by the Virtual File's Originator indicating when the file was made avaiable for transmission.
userData - May be used by the Odette FTP in any way. If unused it should be initialized to spaces. It is expected that a bilateral agreement exists as to the meaning of the data.
destination - The Identification Code for the final recipient of the Virtual File. This is the location that will look into the Virtual File content and perform mapping functions. It is also the location that creates the End to End Response (EERP) command for the received file.
originator - The Identification Code from the Originator of the Virtual File. It is the location that created (mapped) the data for transmission.
recordFormat - Virtual File format (Fixed, Variable, Unustructured, Text File). Used to calculate the restart position.
maxRecordSize - Length in octets of the longest logical record which may be transferred to a location. Only user data is included. If File format is 'T' or 'U' then this attribute must be set to '00000'
fileSize - File Size, 1K (1024 octets) blocks.
restartOffset - Restart position.
Returns:
The Start File command with the corresponding values.
Throws:
OdetteFTPException

startFilePositiveAnswer

public static CommandExchangeBuffer startFilePositiveAnswer(int answerCount)
                                                     throws OdetteFTPException
Create the Start File Positive Answer command. The only parameter indicate which position the Listener agree to restart the receive of a previous Virtual File.

Parameters:
answerCount - int lower or equal to restart count specified by the Speaker in the Start File (SFID) command. If restart facilities are not avaiable, a count of zero must be specified.
Returns:
The Start File Positive Answer command with the corresponding values.
Throws:
OdetteFTPException

startFileNegativeAnswer

public static CommandExchangeBuffer startFileNegativeAnswer(AnswerReason reason,
                                                            boolean retry)
                                                     throws OdetteFTPException
Create the Start File Negative Answer command containing the the reason why transmission can not proced.
This retry parameter is used to advise the Speaker if it should retry at a latter point in time due to a temporary condition at the Listener site, such as a lack of storage space. It should be used in conjunction with the Answer Reason code.

Parameters:
reason - Answer Reason.
retry - true if the transmission may be retried latter, or false to don't retry again.
Returns:
The Start File Negative Answer command with the corresponding values.
Throws:
OdetteFTPException

setCredit

public static CommandExchangeBuffer setCredit(java.lang.String reserved)
                                       throws OdetteFTPException
Create the Set Credit command which is used to avoid congestion at the protocol level a flow control.

Parameters:
reserved - This field is reserved for future use.
Returns:
The Set Credit command with the corresponding values.
Throws:
OdetteFTPException

endFile

public static CommandExchangeBuffer endFile(int recordCount,
                                            long unitCount)
                                     throws OdetteFTPException
Create the End File command indicating the count of records and overall octets from the transmitted Virtual File.
The count will express the real size of the file (before compression, header not included). The total count is always used, even during restart processing.

Parameters:
recordCount - For FIXED or VARIABLE record formats, the exact record count. For UNSTRUCTURED or TEXTFILE, must be zero.
unitCount - Exact number of units (octets) transmitted.
Returns:
Throws:
OdetteFTPException

endFilePositiveAnswer

public static CommandExchangeBuffer endFilePositiveAnswer(boolean changeDirection)
                                                   throws OdetteFTPException
Create the End File Positive Answer command indicating whether the Listener is requesting or not a Change Direction (CD) command from Speaker or not.

Parameters:
changeDirection - Change Direction Indicator.
Returns:
The End File Positive Answer command with the corresponding values.
Throws:
OdetteFTPException

endFileNegativeAnswer

public static CommandExchangeBuffer endFileNegativeAnswer(AnswerReason reason)
                                                   throws OdetteFTPException
Create the End File Negative Answer command providing the reason for stopping transfer.

Parameters:
reason - Reason why transmission can not proceed.
Returns:
The End File Negative Answer command with the corresponding values.
Throws:
OdetteFTPException

endSession

public static CommandExchangeBuffer endSession(EndSessionReason reason)
                                        throws OdetteFTPException
Create the End Session command indicating the reason code for terminating the session.

Parameters:
reason - End Session Reason.
Returns:
The End Session command with the corresponding values.
Throws:
OdetteFTPException

changeDirection

public static CommandExchangeBuffer changeDirection()
                                             throws OdetteFTPException
Create the Change Direction command.

Returns:
The Change Direction command with the corresponding values.
Throws:
OdetteFTPException

endToEndResponse

public static CommandExchangeBuffer endToEndResponse(java.lang.String dataSetName,
                                                     java.lang.String reserved,
                                                     java.util.Date dateTime,
                                                     java.lang.String userData,
                                                     java.lang.String destination,
                                                     java.lang.String originator)
                                              throws OdetteFTPException
Create the End to End Response command with given parameters.

Parameters:
dataSetName - Dataset name of the Virtual File being transfered.
reserved - This field is reserved for future use.
dateTime - Virtual File date and time indicating when the file was made available for transmission.
userData - May be used by the Odette FTP in any way.
destination - Identification code from the Originator of the Virtual File, which created (mapped) the data for transmission.
originator - Identification code of the Final Recipient of the Virtual File. This is the location that creates the EERP for the received file.
Returns:
The End to End Response command with the corresponding values.
Throws:
OdetteFTPException

readyToReceive

public static CommandExchangeBuffer readyToReceive()
                                            throws OdetteFTPException
Create the Ready to Receive command.

Returns:
The Ready to Receive command with the corresponding values.
Throws:
OdetteFTPException

getParameter

public java.lang.String getParameter(java.lang.String name)
Return a Command Exchange Buffer parameter value for the specified field.

Parameters:
name - Field key name.
Returns:
Corresponding parameter value for a given field.

getParameters

public java.util.Collection getParameters()
Returns:
Collection of strings representing parameters.

setParamater

protected void setParamater(java.lang.String name,
                            java.lang.String value)
                     throws OdetteFTPException
Set a parameter in command stream with the given value.

Parameters:
name - parameter name (as defined in protocol specification).
value - String representing the given value as expected by protocol specification.
Throws:
OdetteFTPException

parse

protected void parse(java.nio.ByteBuffer rawBuffer)
              throws OdetteFTPException
Method used to set configure this object with the value from parsing the given raw buffer. Raw buffer usually comes directly from transportation stream.

Specified by:
parse in class OdetteExchangeBuffer
Parameters:
rawBuffer - raw command exchange buffer to parse.
Throws:
BufferCorruptedException - When buffer has a invalid remaing size, or there's a wrong command length (and the strictly check format option is set).
OdetteFTPException


Copyright © 2005 ObjectWeb Consortium. All Rights Reserved.