com.cysols.iodef.transport
Class IodefXMLFileAcceptor

java.lang.Object
  extended by com.cysols.iodef.transport.IodefXMLFileAcceptor

public abstract class IodefXMLFileAcceptor
extends Object

This class provides IODEF message reception API from network through the various ways. By using the specified IodefDocumentWriter instance (given by its constructor), it stores an incident to the data repository like Database. After obtaining IODEF message, for example, by Email, FTP, HTTP or other ways, it is possible to use this class and to call received method. The received method tries to store the received iodef document into the data repository which depends on the specified IodefDocumentWriter instance.

This is an abstract class. So it is necessary to implement the concrete sub class. When received method is called, this super class calls "notifySuccess" method or "notifyFailure" method. The former is called if the IODEF Document is stored correctly. The latter is called if failed. Only the over-ridden methods are needed in the concrete sub class. Logging, Notification or something will be implemented in the methods.


Field Summary
protected  IODEFElementCreator creator
          Instance variable of IODEF ElementCreator.
protected  IodefDocumentWriter writer
          Instance variable of IodefDocumentWriter, which is used for storring the received IODEF Document
 
Constructor Summary
IodefXMLFileAcceptor(IodefDocumentWriter writer, IODEFElementCreator creator)
          Default Constructor, which is called by its sub class.
 
Method Summary
 IODEFDocument loadIODEFDocument(File xmlFile)
          Returns an array of IODEF Document instances from the specified File instance.
 IODEFDocument loadIODEFDocument(String xmlFilePath)
          Returns an array of IODEF Document instances from the specified IODEF xml file.
 void notifyFailure(IODEFDocument iodef, Throwable e)
          Called when the IODEF Document could not be stored after received method is called.
 void notifySuccess(IODEFDocument iodef)
          Called when the IODEF Document is stored correctly after received method is called.
 void received(File xmlFile)
          Call this IODEF xml file is obtained from network.
 void received(IODEFDocument iodef)
          Call this after an IODEF Document is obtained from network by the respective ways.
 void received(IODEFDocument[] iodefs)
          Some IODEF Documents are stored at the same time.
 void received(String xmlFilePath)
          Call this IODEF xml file is obtained from network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

protected IodefDocumentWriter writer
Instance variable of IodefDocumentWriter, which is used for storring the received IODEF Document


creator

protected IODEFElementCreator creator
Instance variable of IODEF ElementCreator. Either just creator or name space-based creator will be given.

Constructor Detail

IodefXMLFileAcceptor

public IodefXMLFileAcceptor(IodefDocumentWriter writer,
                            IODEFElementCreator creator)
Default Constructor, which is called by its sub class. The specified IodefDocumentWriter instance is used for storing the received instance.

Parameters:
writer - concrete instance of IodefDocumentWriter. The type of repository in which IODEF Document are stored depends on the instance.
Method Detail

notifySuccess

public void notifySuccess(IODEFDocument iodef)
Called when the IODEF Document is stored correctly after received method is called. This concrete implementation will be in its sub class.

Parameters:
iodef - the stored IODEF document instance.

notifyFailure

public void notifyFailure(IODEFDocument iodef,
                          Throwable e)
Called when the IODEF Document could not be stored after received method is called. This concrete implementation will be in its sub class.

Parameters:
iodef - IODEF Document instance not to be stored.
e - the cause of failure to store

received

public void received(IODEFDocument iodef)
Call this after an IODEF Document is obtained from network by the respective ways. The received instance is stored by using IodefDocumentWriter. And notifySuccess method is called in the case of success. Otherwise notifyFailure is called.

Parameters:
iodef - IODEF Document instance to be stored.

received

public void received(IODEFDocument[] iodefs)
Some IODEF Documents are stored at the same time. Basically same as received(IODEFDocument) method. notifySuccess or notifyFailure method is called for each IODEF DOcument.

Parameters:
iodefs - an array of IODEF Document instances to be stored.

received

public void received(String xmlFilePath)
              throws FileNotFoundException,
                     XMLReaderException
Call this IODEF xml file is obtained from network. Same as received(IODEFDocument[]) method after IODEF Documents are read from the xml file.

Parameters:
xmlFilePath - the file path of IODEF xml file
Throws:
FileNotFoundException - The specfied xml file is not found.
XMLReaderException - Unable to read the IODEF Document from the specified file.

received

public void received(File xmlFile)
              throws FileNotFoundException,
                     XMLReaderException
Call this IODEF xml file is obtained from network. Same as received(IODEFDocument[]) method after IODEF Documents are read from the xml file.

Parameters:
xmlFile - the File instance of IODEF xml file
Throws:
FileNotFoundException - The specfied xml file is not found.
XMLReaderException - Unable to read the IODEF Documents from the specified file.

loadIODEFDocument

public IODEFDocument loadIODEFDocument(String xmlFilePath)
                                throws FileNotFoundException,
                                       XMLReaderException
Returns an array of IODEF Document instances from the specified IODEF xml file.

Parameters:
xmlFilePath - the file path of IODEF xml file
Returns:
an array of IODEF Document instances defined in the specified xml file.
Throws:
FileNotFoundException - The specfied xml file is not found.
XMLReaderException - Unable to read the IODEF Documents from the specified file.

loadIODEFDocument

public IODEFDocument loadIODEFDocument(File xmlFile)
                                throws FileNotFoundException,
                                       XMLReaderException
Returns an array of IODEF Document instances from the specified File instance.

Parameters:
xmlFile - the File instance of IODEF xml file
Returns:
an array of IODEF Document instances defined in the specified xml file.
Throws:
FileNotFoundException - The specfied xml file is not found.
XMLReaderException - Unable to read the IODEF Documents from the specified file.