Publication Completion

Once all target items have been processed, Data Hub needs to be notified that the publication is complete. This request is handled by the PublicationActionService method completeTargetSystemPublication(). The method takes in a com.hybris.datahub.dto.publication.PublicationResult.

Any target items that could not be imported need to be reported as part of the publication result error list. For asynchronous processing, you could create a REST endpoint in your code that delegates to this service method.

The Data Hub base URL is passed as a String argument to the adapter publish method. You can pass the base URL on to your import client to build the REST URL for the publication completion callback. The following code snippet shows you how to use the native Data Hub PublicationActionService and its completeTargetSystemPublication() method to help create a publication result error list..

import com.hybris.datahub.dto.publication.PublicationResult;
import com.hybris.datahub.service.PublicationActionService;
 
[...]
 
private void completePublication(final TargetSystemPublication targetSystemPublication, final List<ErrorData> errors) {
    final PublicationResult publicationResult = new PublicationResult();
    publicationResult.setExportErrorDatas(errors);
    publicationActionService.completeTargetSystemPublication(targetSystemPublication.getPublicationId(), publicationResult);
}

What's next?

You now have all of the basic tools to put together a complete output adapter. Additional, custom implementation may be required for your extension, in addition to what is described here. But as long as you cover at least these minimum steps, you should be able to create a robust custom output adapter for any target system.