Derivatives of RestService
Derivatives of RestService interface facilitates creation of RESTful implementation of standard services.
Simple search (simple-search)
simple-search service:com.hcl.unica.cms.integration.service.search.RestSearchServiceThe
com.example.service.rest.SimpleSearchServiceclass in asset-integration-starter project is a quick starter implementation for RESTfulsimple-searchservice. Its parent iscom.hcl.unica.cms.integration.service.search.RestSearchServiceclass.The
RestSearchServiceclass has a type parameter RS, which represents the type of response (post deserialization) received from the remote REST API. In this case it isSimpleSearchResponseclass defined inside theasset-integration-starterproject.RestSearchServiceclass implementsRestServiceinterface and defines theSearchRequestclass as the type argument RQ forRestService. Thus, the object ofSearchRequestbecomes input to all thesimple-searchservices (same input is used for Functional counterpart of simple-search as well).SearchRequestclass is part of the Asset Picker SDK.In addition to defining the input type for the
simple-searchservice,RestSearchServiceclass also overrides thetransformResponsemethod and defines return value of this method to be ofContentPagetype.ContentPageis also part of the Asset Picker SDK and encapsulates the search result and associated pagination details.The plugin must extend its
simple-searchimplementation fromRestSearchServiceservice in order to be recognized as asimple-searchservice by Asset Picker.RestSearchServiceextends fromcom.hcl.unica.cms.integration.service.search .AbstractSearchServiceabstract class.We recommend looking at
com.aem.service.AemSimpleSearchServiceclass from the aem-integration project to know more about how theSearchRequestclass and theContentPageclass are used during service implementation.com.hcl.unica.cms.integration.service.search.AbstractSearchServiceThis is a common base class for RESTful as well as Functional
simple-searchimplementations. So, the details of this class also apply to the Functional implementation ofsimple-search.This class defines the
com.hcl.unica.cms.integration.service.gateway.SimpleSearchServiceGatewayinterface as the service gateway for thesimple-searchservice. ServiceGateways are the means to programmatically define input and output types of the service and the work with the service. A closer look at this interface tells us that thesimple-searchtakes theSearchRequestobject and returns theContentPageobject.In addition to defining the service interface forsimple-search, it introduces one more abstract method for thesimple-searchservice. Everysimple-searchimplementation must override and implement this new method. Please note that this method is verysimple-searchspecific and has nothing to do with other standard and custom services. The Signature of this new method is as follows:abstract public List<String> getSupportedContentTypes();Implementation of this method returns a list of strings representing the categories of contents or assets to search against in target system. There is no specific semantic associated with the values in this list. It can be any meaningful text. It acts as a filter for client application during search operation. Client application can send values from this list to filter the search items. Values received from the client application can be obtained from the
ExecutionContextobject by navigating through thegetRequestmethod and then callinggetTypes()on it.getRequest()returns theSearchRequestobject which contains the set of supported types the client application has sent to filter the search result. Simple-search implementation deals with these set of values as per the target system���s programming interface and filters the search items accordingly. Look at thegetSupportedContentTypesmethod incom.aem.service.AemSimpleSearchServiceclass in aem-integration project, and how therestrictContentTypesmethod incom.aem.service.simplesearch.SimpleSearchRequestBuilderclass restricts the search result to the selected types.
Asset selection callback (asset-selection callback)
The following are the specialized interfaces and classes available for
asset-selection-callback service:
-
com.hcl.unica.cms.integration.service.assetselectioncallback .RestAssetSelectionCallbackServiceThecom.example.service.rest.ContentSelectionCallbackServiceclass in the asset-integration-starter project is a quick starter implementation for RESTfulasset-selection-callbackservice. Its parent is the following class:com.hcl.unica.cms.integration.service.assetselectioncallback .RestAssetSelectionCallbackServiceThe
RestAssetSelectionCallbackServiceclass has a type parameter RS, which represents the type of response (post deserialization) received from remote REST API. In this case it is String class defined in Standard Java Library.The
RestAssetSelectionCallbackServiceclass implements theRestServiceinterface and defines thecom.hcl.unica.cms.model.request.assetselectioncallback.AssetSelectionDetailsclass to be the type argument RQ for RestService. Thus, the object ofAssetSelectionDetailsbecomes the input to all theasset-selection-callbackservices (Same input is used for Functional counterpart of asset-selection-callback as well). TheAssetSelectionDetailsclass is a part of the Asset Picker SDK. TheAssetSelectionDetailsclass encapsulates the details of an Asset (search item) selected by the client application and the contextual information such as the search query that lead to the search result containing the selected item.Plugin must extend its
asset-selection-callbackimplementation from theRestAssetSelectionCallbackServiceservice in order to be recognized as anasset-selection-callbackservice by the Asset Picker (functional counterpart is also a valid choice to extend from).RestAssetSelectionCallbackServiceextends from the following abstract class:com.hcl.unica.cms.integration.service.assetselectioncallback .AbstractAssetSelectionCallbackService -
com.hcl.unica.cms.integration.service.assetselectioncallback .AbstractAssetSelectionCallbackServiceThis is a common base class for RESTful as well as Functional
asset-selection-callbackimplementations. So, the details of this class mentioned here also applies to the Functional implementation ofasset-selection-callback.The following class defines interface as the service gateway for theasset-selection-callbackservice:com.hcl.unica.cms.integration.service.gateway .AssetSelectionCallbackServiceGatewayServiceGateways are the means to define input and output types of the service and programmatically work with the service. A closer look at this interface tells us that the
asset-selection-callbacktakes theAssetSelectionDetailsobject and returns any Object. Currently, return value fromasset-selection-callbackis ignored by the Asset Picker.