Derivatives of RestService

Derivatives of RestService interface facilitates creation of RESTful implementation of standard services.

Simple search (simple-search)

The following are the specialized interfaces and classes available for the simple-search service:
  • com.hcl.unica.cms.integration.service.search.RestSearchService

    The com.example.service.rest.SimpleSearchService class in asset-integration-starter project is a quick starter implementation for RESTful simple-search service. Its parent is com.hcl.unica.cms.integration.service.search.RestSearchService class.

    The RestSearchService class has a type parameter RS, which represents the type of response (post deserialization) received from the remote REST API. In this case it is SimpleSearchResponse class defined inside the asset-integration-starter project.

    RestSearchService class implements RestService interface and defines the SearchRequest class as the type argument RQ for RestService. Thus, the object of SearchRequest becomes input to all the simple-search services (same input is used for Functional counterpart of simple-search as well). SearchRequest class is part of the Asset Picker SDK.

    In addition to defining the input type for the simple-search service, RestSearchService class also overrides the transformResponse method and defines return value of this method to be of ContentPage type. ContentPage is also part of the Asset Picker SDK and encapsulates the search result and associated pagination details.

    The plugin must extend its simple-search implementation from RestSearchService service in order to be recognized as a simple-search service by Asset Picker.

    RestSearchService extends from com.hcl.unica.cms.integration.service.search .AbstractSearchService abstract class.

    We recommend looking at com.aem.service.AemSimpleSearchService class from the aem-integration project to know more about how the SearchRequest class and the ContentPage class are used during service implementation.

  • com.hcl.unica.cms.integration.service.search.AbstractSearchService

    This is a common base class for RESTful as well as Functional simple-search implementations. So, the details of this class also apply to the Functional implementation of simple-search.

    This class defines the com.hcl.unica.cms.integration.service.gateway.SimpleSearchServiceGateway interface as the service gateway for the simple-search service. 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 the simple-search takes the SearchRequest object and returns the ContentPage object.

    In addition to defining the service interface for simple-search, it introduces one more abstract method for the simple-search service. Every simple-search implementation must override and implement this new method. Please note that this method is very simple-search specific 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 ExecutionContext object by navigating through the getRequest method and then calling getTypes() on it. getRequest() returns the SearchRequest object 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 the getSupportedContentTypes method in com.aem.service.AemSimpleSearchService class in aem-integration project, and how the restrictContentTypes method in com.aem.service.simplesearch.SimpleSearchRequestBuilder class 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
    .RestAssetSelectionCallbackService
    The com.example.service.rest.ContentSelectionCallbackService class in the asset-integration-starter project is a quick starter implementation for RESTful asset-selection-callback service. Its parent is the following class:
    com.hcl.unica.cms.integration.service.assetselectioncallback
    .RestAssetSelectionCallbackService

    The RestAssetSelectionCallbackService class 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 RestAssetSelectionCallbackService class implements the RestService interface and defines the com.hcl.unica.cms.model.request.assetselectioncallback.AssetSelectionDetails class to be the type argument RQ for RestService. Thus, the object of AssetSelectionDetails becomes the input to all the asset-selection-callback services (Same input is used for Functional counterpart of asset-selection-callback as well). The AssetSelectionDetails class is a part of the Asset Picker SDK. The AssetSelectionDetails class 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-callback implementation from the RestAssetSelectionCallbackService service in order to be recognized as an asset-selection-callback service by the Asset Picker (functional counterpart is also a valid choice to extend from).

    RestAssetSelectionCallbackService extends from the following abstract class:
    com.hcl.unica.cms.integration.service.assetselectioncallback
    .AbstractAssetSelectionCallbackService
  • com.hcl.unica.cms.integration.service.assetselectioncallback
    .AbstractAssetSelectionCallbackService

    This is a common base class for RESTful as well as Functional asset-selection-callback implementations. So, the details of this class mentioned here also applies to the Functional implementation of asset-selection-callback.

    The following class defines interface as the service gateway for the asset-selection-callback service:
    com.hcl.unica.cms.integration.service.gateway
    .AssetSelectionCallbackServiceGateway

    ServiceGateways 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-callback takes the AssetSelectionDetails object and returns any Object. Currently, return value from asset-selection-callback is ignored by the Asset Picker.