Class ContentDeliveryClient

java.lang.Object
com.oracle.content.sdk.ContentClient
com.oracle.content.sdk.ContentDeliveryClient

public class ContentDeliveryClient extends ContentClient
This the core class to use for making delivery SDK calls. It must be created by calling ContentSDK.createDeliveryClient(java.lang.String, java.lang.String).

Example for creating a ContentDeliveryClient

It is best to create the delivery client object once and reuse it in your app. The only reason you would need more than one delivery client is if you were making calls to multiple servers. To change any of the settings, it is necessary to re-create a new content delivery client.
   

 // The simplest way to create a delivery client is to pass
 // in a server url and channel token like this:

 // create client API we'll use to make SDK calls
 contentDeliveryClient = ContentSDK.createDeliveryClient(
      serverUrl,          // server url that will service sdk requests
      channelToken,      // channel token (required)
 );

 // To enable the cache (recommended), provide a cache dir as an additional parameter)

  * contentDeliveryClient = ContentSDK.createDeliveryClient(
  *      serverUrl,            // server url that will service sdk requests
  *      channelToken,         // channel token (required)
  *      context.getHttpCacheDir() // enables all caches
  * );

Build search request and make SDK Call

This example would make a call to search for items based on a type string
.
 See ContentRequest for the various
 types of calls available including synchronous, async, and observables using RxJava.

 // this shows how to build a search request
 SearchContentItemsRequest searchRequest = new SearchContentItemsRequest(deliveryClient)
        .type(searchType);   // search for items matching this type

 // make an asynchronous SDK call to get a list of content items based on the criteria
 searchRequest.fetchAsync(::searchCallback);

 // another alternative that makes a synchronous version of the same call
 searchCallback( searchRequest.fetch() );
 }

Handle the callback response

The callback method specified in will be called when the SDK operation is complete or an error occurred.

Here is an example of a callback method to handle the search call from above: void searchCallback(ContentResponse<ContentSearchResult> response) { // if there was an error, handle that exception if (!response.isSuccess()) { handleContentException(response.getException()); } else { // success, so get the ContentSearchResult object from the response ContentSearchResult result = response.getResult(); // now we have a list of ContentItems to go through from the response for (ContentItem item : result.getItems()) { // process each content item } } }
  • Method Details

    • getApi

      public RestApiInterfaceV1 getApi()
      Get the retrofit api interface used internally to make SDK calls.
      Returns:
      retrofit interface
    • buildDigitalAssetDownloadUrl

      public String buildDigitalAssetDownloadUrl(@NotNull @NotNull String digitalAssetId)
      When a DigitalAsset has been fully retrieved with all properties, the method DigitalAsset.getNativeDownloadUrl() ()} should be used to get the download url as defined on the server. If you only have a reference to a DigitalAsset, this method can be used to manually build a download url using the DigitalAsset id. The returned url will also include any authentication parameters such as the channel token.

      Although more efficient than having to download the full digital asset, manually building the pathName may not work in all cases so if the url returned from this method is not working, get the full digital asset object and call DigitalAsset.getNativeDownloadUrl() ()}.

      Specified by:
      buildDigitalAssetDownloadUrl in class ContentClient
      Parameters:
      digitalAssetId - the Digital asset id to use for building a download url
      Returns:
      URL to download the asset
    • buildDigitalAssetThumbnailUrl

      public String buildDigitalAssetThumbnailUrl(@NotNull @NotNull String digitalAssetId)
      Builds the thumbnail url. See buildDigitalAssetDownloadUrl(String) for more detail.
      Parameters:
      digitalAssetId - digital asset to use for building url
      Returns:
      URL to render the thumbnail image