IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > FTP > Reference
Custom file splitting
You can implement a custom class containing the splitting logic. The adapter provides a Java™ interface for the class. WebSphere Adapter for FTP, version 7.5 supports additional splitting methods for the inbound process. Hence, there are two different interfaces available for the inbound and outbound process.
Interface for outbound operations
Use the com.ibm.j2ca.utils.filesplit.SplittingFunctionalityInterface interface for the outbound operations.
Following are the details of the interface:
public interface SplittingFunctionalityInterface extends Iterator{ public int getTotalBOs(String filename) throws SplittingException; public void setBODetails(String filename, int currentPosition, int totalBOs, boolean includeEndBODelimiter) throws SplittingException; public void setSplitCriteria(String splitCriteria); public void setEncoding(String encoding); public void setLogUtils(LogUtils logUtils); public boolean isSplitBySize()}
- public int getTotalBOs(String filename) throws SplittingException
This method returns the total number of business objects present in the event file specified in the filename.
- public void setSplitCriteria(String splitCriteria)
This method is used to set the splitCriteria based on the number of business objects present in the event file. Each business object is returned during the next() call.
- public void setLogUtils(LogUtils logUtils)
This method is used to set the LogUtils object, which is used to write trace and log messages to the files.
- public void setEncoding(String encoding)
This method is used to set the encoding for the content of the event file. This encoding is used while reading the file content and for the splitCriteria.
- public void setBODetails(String filename, int currentPosition, int totalBOs, boolean includeEndBODelimiter) throws SplittingException
This method is used to set the details for the business object to be returned during the next() call. The currentPosition parameter specifies the position of the business object to be returned. If the includeEndBODelimiter parameter is set to true, the business object content is retrieved based on the splitCriteria. Run this method before every next() call to retrieve the business object content as set in this method.
In addition, the iterator contains three methods, hasNext(), next(), and remove(), which must be implemented. The next() method returns the business object content (as a byte[]) for the business object position set in the setBODetails() method. If the position of the business object is not set, it fails. The hasNext() method indicates if the business object position set in the setBODetails() exists or not. Before a hasNext() call, the setBODetails() method must be called. The remove() method is called for each of the business object entries being deleted from the Event persistence table. Ensure not to delete the event file and only clean up the resources that are being used.
- public boolean isSplitBySize()
This method returns the value True if the event file is parsed based on the size. And returns the value False if the event file is parsed based on any other criteria, such as, delimiter.
Interface for inbound operations
Use the com.ibm.j2ca.utils.filesplit.InboundSplittingFunctionalityInterface interface for the inbound operations.
The custom splitting class for an inbound operation created in the earlier version of the adapter does not work with version 7.5.
Following are the details of the interface:
public interface InboundSplittingFunctionalityInterface{ public Hashtable getBOs(String filename,int quantity, long lastBO,long lastBOPos,boolean withDelim) throws SplittingException,MissingDataException; public void setBODetails(String filename, long currentBO, long startPos, long endPos) throws SplittingException; public Object getBOContent(); public boolean hasMoreBO(); public void remove(); public void setSplitCriteria(String splitCriteria); public void setEncoding(String encoding); public void setLogUtils(LogUtils logUtils); public boolean isSplitBySize();}
- public Hashtable getBOs(String filename, int quantity, long lastBOCount, long lastBOPos, boolean includeEndBODelimiter) throws SplittingException,MissingDataException
This method returns the business objects retrieved from the file specified in the filename in the form a hashtable. The hashtable that is returned contains the business object count (key) and the start/end positions of that business object (a long array of two elements). The quantity parameter specifies the number of business objects to be retrieved. The lastBOCount parameter specifies the number of business objects retrieved until when the file was previously read. The lastBOPos parameter specifies the end position of the business object when the file was previously read. The includeEndBODelimiter parameter specifies if the split criteria is included in the content returned for the business object. If the parameter is set to True the delimiter is included in the business object data.
- public void setBODetails(String filename, long currentBO, long startPosition, long endPosition) throws SplittingException
This method is used to set the details for the current business object. Thereafter, the getBOContent() method retrieves the content of the business object specified in the currentBO. The startPosition and endPosition parameters specifie the start and end position for the business object in the file.
- public Object getBOContent()
The getBOContent() method returns the business object content (as a byte[]) for the details set in setBODetails() method.
If the start and end position of the business object is not set in the setBODetails() method then the getBOContent() method fails.
- public boolean hasMoreBO()
This method returns the value True if there are unread business objects existing in the file after the last call to the getBOs() method.
- public void remove()
The remove() method is called for each of the business object entry being deleted from the Event persistence table. Ensure that you do not delete the event file and only clean up the resources that are being used.
- public void setSplitCriteria(String splitCriteria)
This method returns the splitCriteria set based on the number of business objects in the event file. Each business object is returned during the getBOContent() call.
- public void setLogUtils(LogUtils logUtils)
This method is used to set the LogUtils object, which is the class used to write trace and log messages to the files.
- public void setEncoding(String encoding)
This method is used to set the encoding for the content of the event file. This encoding is used while reading the file content and for the splitCriteria.
- public boolean isSplitBySize()
This method returns the value True if the event file is parsed based on the size. And returns the value False if the event file is parsed based on any other criteria, such as, delimiter.
Related concepts: