net.sf.xbus.technical.as400
Class AS400FileReceiver

java.lang.Object
  extended by net.sf.xbus.technical.as400.AS400FileBase
      extended by net.sf.xbus.technical.as400.AS400FileReceiver
All Implemented Interfaces:
TAResource, Receiver, ReceiverSingleInterface
Direct Known Subclasses:
AS400ByteArrayListReceiver, AS400LineReaderReceiver

public class AS400FileReceiver
extends AS400FileBase
implements Receiver, TAResource, ReceiverSingleInterface

The AS400FileReceiver receives a request, reads the files on the AS400 machines into tstrings and calls the application layer.

Configuration:

Chapter Section Key Content
System Interface Filename Path name that represents an object in the
QSYS library file system on the AS400 machine
System Interface FinalResolution Three actions are possible with the file after processing:
preserve, rename or delete
System Interface OnError Three actions are be possible with the file when an unrecoverable error has occured:
preserve, rename or delete
System Interface Encoding Specified character encoding of the interface (Optional)
Base ReceiverTimeout Seconds Global timeout value for AS400FileReceiver.
If any error occurs the AS400FileReceiver tries again in this time.
Base Retry Count How many additional attempts are started after an error occured?


Field Summary
protected  com.ibm.as400.access.AS400 mAS400System
          AS400 object that represents the iSeries system that contains the file
protected  java.lang.String mEncoding
          File encoding
protected  com.ibm.as400.access.SequentialFile mOriginFile
          Represents an AS/400 physical or logical file.
protected  com.ibm.as400.access.QSYSObjectPathName mQSYSObject
          QSYSObjectPathName represents an object in the integrated file system
 
Fields inherited from class net.sf.xbus.technical.as400.AS400FileBase
mConverter
 
Constructor Summary
AS400FileReceiver()
           
 
Method Summary
 void close()
          Not implemented for the iSeries integrated file system
 void commit()
          Implemented method commit from the TAResource interface.
protected  boolean doReceive(XBUSSystem xbusSystem)
          Manages the process of receipt for a specifc XBUSSystem.
 java.lang.String getOnError(Configuration config, java.lang.String system)
          Determines the action which should happen in case of an error from the standard configuration and checks its conformity with the allowed ones: Preserve -the source file remains without modifications Rename   - the source file member is renamed Delete or DeleteFile   - the source file is deleted DeleteMember   - the source file member is deleted
protected  java.lang.Object getRequestContent()
          getRequestContent delivers the content of the request.
 java.lang.String getResolution(Configuration config, java.lang.String system)
          Determines the final resolution (action after successful file processing) for the given system name from the standard configuration and checks its conformity with the allowed ones: Preserve -the source file remains without modifications Rename   - the source file member is renamed Delete or DeleteFile   - the source file is deleted DeleteMember   - the source file member is deleted CallProgram   - a parameterless program is called on the AS400, its path is given in the configuration
 java.lang.String getType()
          A Receiver can receive data either as a String or as an Object from a neighboring system.
 void open()
          Not implemented for the iSeries integrated file system
 void readConfiguration(java.lang.String system)
          Reads standard configuration and stores following data in the class variables.
 void receive(java.lang.String systemName)
          This method manages the receiving of message for one neighbor system.
 void rollback()
          Implemented method rollback from TAResource neglects all changes made so far (file locking).
 void setAS400System(com.ibm.as400.access.AS400 aS400System)
          Sets the aS400System in AS400FileReceiver object.
 
Methods inherited from class net.sf.xbus.technical.as400.AS400FileBase
callAS400Program, copyFile, deleteFile, deleteMember, getEncoding, getRenamedMember, releaseLock, renameFile, setLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mAS400System

protected com.ibm.as400.access.AS400 mAS400System
AS400 object that represents the iSeries system that contains the file


mOriginFile

protected com.ibm.as400.access.SequentialFile mOriginFile
Represents an AS/400 physical or logical file. Allows the user to use commitment control when accessing an AS/400 file and access the records in an AS/400 file sequentially or by record number.


mQSYSObject

protected com.ibm.as400.access.QSYSObjectPathName mQSYSObject
QSYSObjectPathName represents an object in the integrated file system


mEncoding

protected java.lang.String mEncoding
File encoding

Constructor Detail

AS400FileReceiver

public AS400FileReceiver()
Method Detail

receive

public void receive(java.lang.String systemName)
This method manages the receiving of message for one neighbor system.

The system is specified by its name. Due to wildcards in this name it may really describe serveral interfaces. All these will be processed. Thus, first the list of XBUSSystems for the given system name is determined by replacing the wildcards.

After that for each XBUSSystem the doReceive(XBUSSystem) method is invoked, where requested interface file(s) is (are) read out into a character string. The XBUSSystem and the string are passed to the application layer.

Note:
The retry mechanism in this method first attempts processing each XBUSSystem. Those which cause errors are put into a list and this list is the base for the next retry.

Specified by:
receive in interface ReceiverSingleInterface
Parameters:
systemName - name of the system to receive data from
Throws:
XException - if something goes wrong

doReceive

protected boolean doReceive(XBUSSystem xbusSystem)
Manages the process of receipt for a specifc XBUSSystem. This method is provided to do the following:
  1. replace wildcards in the filename with the dealer information
  2. create copy and backup files, depending on the resolution
  3. read file into String
  4. call application layer
  5. determine the result in sense of success/no success

Parameters:
xbusSystem - XBUSSystem object with information of this neighbor-system to be read
Throws:
XException - if any errors is occurs which is not treated in the application layer

getRequestContent

protected java.lang.Object getRequestContent()
                                      throws XException
getRequestContent delivers the content of the request. Subclasses may define their own request content.

Returns:
the interface file content as String but casted to Object for compliance reasons
Throws:
XException - if file can not be read or any I/O error occurs

readConfiguration

public void readConfiguration(java.lang.String system)
                       throws XException
Reads standard configuration and stores following data in the class variables.

Filename path name that represents an object in the QSYS library file system
Resolution actions actions to be taken in case of successfull transmission, error and empty source file
Encoding specified character encoding of the interface

Parameters:
system - System name to be read
Throws:
XException - if the configuartion is not available or a mandatory key cannot be read
See Also:
getResolution(Configuration, String), AS400FileBase.getEncoding(AS400, String)

getResolution

public java.lang.String getResolution(Configuration config,
                                      java.lang.String system)
                               throws XException
Determines the final resolution (action after successful file processing) for the given system name from the standard configuration and checks its conformity with the allowed ones:

Preserve -the source file remains without modifications
Rename   - the source file member is renamed
Delete or DeleteFile   - the source file is deleted
DeleteMember   - the source file member is deleted
CallProgram   - a parameterless program is called on the AS400, its path is given in the configuration

Parameters:
config - Instance of the Configuration
system - Sytem name for which resolution must be read.
Returns:
final resolution as String (Preserve, Rename, Delete, DeleteFile, DeleteMember or CallProgram)
Throws:
XException - if resolution value is not configured or not known

getOnError

public java.lang.String getOnError(Configuration config,
                                   java.lang.String system)
                            throws XException
Determines the action which should happen in case of an error from the standard configuration and checks its conformity with the allowed ones:

Preserve -the source file remains without modifications
Rename   - the source file member is renamed
Delete or DeleteFile   - the source file is deleted
DeleteMember   - the source file member is deleted

Parameters:
config - Instance of the Configuration
system - Sytem name which resoltion must be read.
Returns:
error case action as String (Preserve, Rename, Delete, DeleteFile, DeleteMember)
Throws:
XException - if the onError key is missing or unknown

setAS400System

public void setAS400System(com.ibm.as400.access.AS400 aS400System)
Sets the aS400System in AS400FileReceiver object.

Parameters:
aS400System - The aS400System to set

commit

public void commit()
            throws XException
Implemented method commit from the TAResource interface. The purpose of commit actions is to remove any backup information that had been created during processing (transaction) in the iSeries integrated file system. Depending on the Resolution, the following actions are carried out:

Resolution Action
Preserve  1. release file lock
Rename  1. release file lock
 2. rename file
Delete/DeleteFile  1. release file lock
 2. delete file
DeleteMember  1. release file lock
 2. delete member
CallProgram  1. release file lock
 2. call the specified terminator program

Specified by:
commit in interface TAResource
Throws:
XException - if accessing the interface file or perfoming the configured action fails
See Also:
TAResource.commit()

rollback

public void rollback()
              throws XException
Implemented method rollback from TAResource neglects all changes made so far (file locking).

Specified by:
rollback in interface TAResource
Throws:
XException - if locks cannot be released
See Also:
TAResource.rollback()

open

public void open()
Not implemented for the iSeries integrated file system

Specified by:
open in interface TAResource
See Also:
TAResource.open()

close

public void close()
Not implemented for the iSeries integrated file system

Specified by:
close in interface TAResource
See Also:
TAResource.close()

getType

public java.lang.String getType()
Description copied from interface: Receiver
A Receiver can receive data either as a String or as an Object from a neighboring system.

Specified by:
getType in interface Receiver