The Data Hub File Adapter

The Data Hub File Adapter is the adapter used for Data Hub documentation tutorials. It writes publication output to a file in the filesystem.

The Data Hub File Adapter implements a class called TargetItemFileWriter that writes publication output in CSV format to a file in the local filesystem.

No configuration is necessary or available for the adapter itself. To use the adapter, simply place it in the /opt/datahub/extensions directory. To output to the adapter, configure your target system in your target XML as follows, then remake the target JAR, and place it in /opt/datahub/extensions.

	<targetSystem>
		<name>FileAdapterTargetSystem</name>
		<type>HybrisCore</type>
		<exportURL/>
		<userName/>
		<password/>
		<exportCodes/>
		
		...
		
	 </targetSystem>

The target system type must be HybrisCore. There is no need to supply an export URL or authentication credentials. Once the changes are complete, restart Data Hub to load both the adapter, and the new target JAR.

After successful publication using the adapter, the output CSV file has the name <Target System Name>_<Target System Publication ID>_<Target Item Type>.csv. For example, if your TargetSystemPublication is 4, and your target item type is apparelProduct, the output file is called FileAdapterTargetSystem_4_apparelProduct.csv. The file is written to the same directory as the Data Hub startup script. By default the path is <TOMCAT_HOME>/bin.

If the output file is written successfully, the log output contains the following:

2016-06-21 12:36:22,926 [INFO] [c.h.d.s.i.PublicationActionHandler] Publishing to FileAdapterTargetSystem

If the output file write fails, log output contains the following, which includes a full stack trace:

2016-06-21 12:36:22,926 [INFO] [c.h.d.s.i.PublicationActionHandler] Error writing publication to file

Subsequent publications are written to new files with the new Target System Publication ID. For example, FileAdapterTargetSystem_5_ApparelProduct.csv, followed by FileAdapterTargetSystem_6_ApparelProduct.csv. Note that if you have configured kernel.autoInitMode=create-drop and restart Data Hub , your database is truncated, and publication IDs are reset. If you already have a file with the same IDs as the new publication, the new output is appended to the end of the existing file. If this behaviour is not desirable, delete or move all existing output files before initiating new publications.

The file adapter is available for download in the Data Hub Solution Book.