Once the items are composed into canonical items, it is time to publish them.
Context
Follow the steps to publish the canonical items and check to see if the publication was successful.
Procedure
Before you can publish, add the target adapter extension to your /opt/datahub/extensions folder. The extension is available from the Solution Book. The file contains datasets, extensions, adapters, and other useful items to help you learn about Data Hub more quickly.
Download the Data Hub File Adapter datahub- and place it in /opt/datahub/extensions.
If Tomcat is running, stop it and restart it.
Save the following to a new file called datafile2, in the same location as the Hello World datafile.
The previous code triggers a publication from a defined pool, to a specific target system, as follows:
"poolname": "GLOBAL" - poolname refers to the data pool in Data Hub where the data is stored. It is named GLOBAL.
"targetSystemPublications" is intended to gather the necessary information about the target system
"targetSystemName": "FileAdapterTargetSystem" - defines the name of the target system receiving the publication. In this case, it is the FileAdapterTargetSystem.
From a command prompt in the folder where datafile2 is, issue the following cURL command to launch publication.
On the Data Hub side, you get output indicating the progress of the publication. The following are the key elements of this output.
2016-06-21 12:36:22,639 [DEBUG] [c.h.d.s.i.DefaultEventPublicationService] Publishing data hub event : PerformPublicationEvent{actionId=1, systemUrl='http://localhost:8080/datahub-webapp/v1', targetPublicationIds=[1]}
.
2016-06-21 12:36:22,814 [DEBUG] [c.h.d.s.i.DefaultTargetItemService] CreatingTarget Items for type targetProduct from 1 Canonical Items in Pool GLOBAL
.
2016-06-21 12:36:22,926 [INFO] [c.h.d.s.i.PublicationActionHandler] Publishing to FileAdapterTargetSystem
.
2016-06-21 12:36:23,050 [DEBUG] [c.h.d.s.p.i.DefaultDataHubPublicationService] setting publication status to SUCCESS
From a command prompt, issue the following cURL command to confirm that the publication has a status of SUCCESS.
curl -k -u admin:<password> --request GET https://localhost:8443/datahub-webapp/v1/pools/GLOBAL/publications
Check the file system where Tomcat was started (<TOMCAT_HOME>). Here, find a file named FileAdapterTargetSystem_2_TargetProduct.csv. This file contains the actual publication output from the adapter, which should be as follows:
description,identifier,name
Hello Data Hub!,1,Data Hub
Results
Congratulations! You've just successfully published your first set of target data. When sent in a POST request to Data Hub, the contents of datafile2 triggered a publication of all data in the specified pool. The resulting target item was picked up by the output adapter which then wrote the data to the output file. There were no complex data transformations in your data model, only one-to-one mappings. Therefore the output was the same as the input. The only thing that has changed is the column headers.