Class AbstractFileFeedPublisher
java.lang.Object
com.broadleafcommerce.datafeed.service.publisher.file.AbstractFileFeedPublisher
- All Implemented Interfaces:
DataFeedPublisher
,org.springframework.core.Ordered
- Direct Known Subclasses:
CommerceManagerFeedAPIPublisher
,MerchantCenterSFTPPublisher
A commonly useful starting point for
DataFeedPublisher
implementations that produce and
upload files to publish feed data.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A special payload to track details about a publish process as it moves through the different steps inprocess(DataFeedPublishRequestDetails)
. -
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionAbstractFileFeedPublisher
(com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.fasterxml.jackson.databind.ObjectMapper objectMapper, List<DataFeedFileTransformer> fileTransformers, List<DataFeedFileSubmitter> fileSubmitters) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Path
createLocalOutputFile
(DataFeedPublishRequestDetails publishRequest) Create the temporary local output file.protected DataFeedFileSubmitResponseDetails
engageFileSubmission
(AbstractFileFeedPublisher.FilePublishContext publishContext) Engage the submission/upload step to takeAbstractFileFeedPublisher.FilePublishContext.getLocalOutputFile()
and send it to the appropriate destination.protected DataFeedFileTransformResponseDetails
engageFileTransformation
(AbstractFileFeedPublisher.FilePublishContext publishContext) Engage the transformation step to read fromDataFeedPublishRequestDetails.getQueriedDataFileLocalCopy()
and transform + serialize those elements toAbstractFileFeedPublisher.FilePublishContext.getLocalOutputFile()
.protected Optional<DataFeedFileSubmitter>
findFileSubmitter
(DataFeedPublishRequestDetails publishRequestDetails) protected Optional<DataFeedFileTransformer>
findFileTransformer
(DataFeedPublishRequestDetails publishRequestDetails) protected List<DataFeedFileSubmitter>
protected List<DataFeedFileTransformer>
protected com.fasterxml.jackson.databind.ObjectMapper
protected com.broadleafcommerce.common.extension.TypeFactory
preparePublishContext
(DataFeedPublishRequestDetails publishRequest) process
(DataFeedPublishRequestDetails publishRequest) Engages the actual data transformation + submission flow to publish data to the specified destination.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.datafeed.service.publisher.DataFeedPublisher
canHandle, getOrder
-
Constructor Details
-
AbstractFileFeedPublisher
public AbstractFileFeedPublisher(com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.fasterxml.jackson.databind.ObjectMapper objectMapper, List<DataFeedFileTransformer> fileTransformers, List<DataFeedFileSubmitter> fileSubmitters)
-
-
Method Details
-
process
Description copied from interface:DataFeedPublisher
Engages the actual data transformation + submission flow to publish data to the specified destination.This method contract is intentionally simple to allow maximum flexibility in implementation.
- Specified by:
process
in interfaceDataFeedPublisher
- Parameters:
publishRequest
- a payload containing various relevant input details for processing- Returns:
- a payload containing details around success/failure
-
preparePublishContext
protected AbstractFileFeedPublisher.FilePublishContext preparePublishContext(DataFeedPublishRequestDetails publishRequest) throws Exception - Throws:
Exception
-
createLocalOutputFile
protected abstract Path createLocalOutputFile(DataFeedPublishRequestDetails publishRequest) throws Exception Create the temporary local output file. Note that this method is intentionally simple and is not intended to be a place where file contents are initialized.Since this is the file that will ultimately be uploaded to the destination, ensure it has the appropriate file name/extensions required by the provider.
Typically, implementations will delegate to
DataFeedFileTransformer.createLocalOutputFile(DataFeedPublishRequestDetails)
.- Parameters:
publishRequest
- the publish request details- Returns:
- a reference to the created file
- Throws:
Exception
- if something went wrong- See Also:
-
engageFileTransformation
protected DataFeedFileTransformResponseDetails engageFileTransformation(AbstractFileFeedPublisher.FilePublishContext publishContext) Engage the transformation step to read fromDataFeedPublishRequestDetails.getQueriedDataFileLocalCopy()
and transform + serialize those elements toAbstractFileFeedPublisher.FilePublishContext.getLocalOutputFile()
.- Parameters:
publishContext
- the publish context- Returns:
- the success/failure details about this operation
-
findFileTransformer
protected Optional<DataFeedFileTransformer> findFileTransformer(DataFeedPublishRequestDetails publishRequestDetails) -
engageFileSubmission
protected DataFeedFileSubmitResponseDetails engageFileSubmission(AbstractFileFeedPublisher.FilePublishContext publishContext) Engage the submission/upload step to takeAbstractFileFeedPublisher.FilePublishContext.getLocalOutputFile()
and send it to the appropriate destination.- Parameters:
publishContext
- the publish context- Returns:
- the success/failure details about this operation
-
findFileSubmitter
protected Optional<DataFeedFileSubmitter> findFileSubmitter(DataFeedPublishRequestDetails publishRequestDetails) -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getFileTransformers
-
getFileSubmitters
-