diff --git a/README.md b/README.md
index 6ddf9ddb..580713e8 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
- 
+
+
+
@@ -10,88 +12,121 @@
-contentful.java - Contentful Java Delivery Library
-==================================================
-[](https://github.com/contentful/contentful.java/actions/workflows/ci.yml)
+# contentful.java - Java Content Delivery Library for Contentful
+
+> Java library for the Contentful [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) and [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/). It helps you to easily access your content stored in Contentful with your Java applications.
-> Java library for [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) and [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/). It helps in easily accessing the content stored in Contentful using Java applications.
+
+
+
+
+
+
+
+
+
+
+
+**What is Contentful?**
-What is Contentful?
--------------------
-[Contentful](https://www.contentful.com) provides a content infrastructure for digital teams to power content in websites, apps, and devices. Contentful, unlike any other CMS, is built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship digital products faster.
+[Contentful](https://www.contentful.com/) provides content infrastructure for digital teams to power websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship their products faster.
Table of contents
-
-- [Core Features](#core-features)
-- [Getting Started](#getting-started)
- - [Setup](#setup)
- - [Client Creation](#client-creation)
- - [First Request](#first-request)
-- [Usage](#usage)
- - [Filtering](#filtering)
- - [Calls in Parallel](#calls-in-parallel)
- - [Paging](#paging)
- - [Includes](#includes)
- - [Unwrapping](#unwrapping)
- - [Preview Mode](#preview)
- - [Sync](#sync)
- - [Http Client](#http-client)
- - [Proguard](#proguard)
- - [Pre-Releases](#pre-releases)
-- [Documentation](#documentation)
-- [License](#license)
-- [Reaching Contentful](#reaching-contentful)
- - [Bugs and Feature Requests](#bugs-and-feature-requests)
- - [Sharing Confidential Information](#sharing-confidential-information)
- - [Getting involved](#getting-involved)
-- [Code of Conduct](#code-of-conduct)
-
+- [contentful.java - Java Content Delivery Library for Contentful](#contentfuljava---java-content-delivery-library-for-contentful)
+ - [Core Features](#core-features)
+ - [Getting started](#getting-started)
+ - [Requirements](#requirements)
+ - [Installation](#installation)
+ - [Your first request](#your-first-request)
+ - [Authorization](#authorization)
+ - [Accessing the Preview API](#accessing-the-preview-api)
+ - [Using the SDK](#using-the-sdk)
+ - [Filtering](#filtering)
+ - [Calls in parallel](#calls-in-parallel)
+ - [Paging](#paging)
+ - [Includes](#includes)
+ - [Cross-space references](#cross-space-references)
+ - [Unwrapping](#unwrapping)
+ - [Select](#select)
+ - [Synchronization](#synchronization)
+ - [Rich text](#rich-text)
+ - [Advanced configuration](#advanced-configuration)
+ - [Http client](#http-client)
+ - [Android and OkHttp 5](#android-and-okhttp-5)
+ - [Proguard](#proguard)
+ - [Documentation & References](#documentation--references)
+ - [Rich Text renderer library](#rich-text-renderer-library)
+ - [Pre-releases](#pre-releases)
+ - [Reach out to us](#reach-out-to-us)
+ - [Have questions about how to use this library?](#have-questions-about-how-to-use-this-library)
+ - [You found a bug or want to propose a feature?](#you-found-a-bug-or-want-to-propose-a-feature)
+ - [You need to share confidential information or have other questions?](#you-need-to-share-confidential-information-or-have-other-questions)
+ - [Get involved](#get-involved)
+ - [Development setup](#development-setup)
+ - [License](#license)
+ - [Code of Conduct](#code-of-conduct)
-Core Features
-=============
+
+
+## Core Features
+
+- Content retrieval through the [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) and [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/).
+- [Synchronization](https://www.contentful.com/developers/docs/concepts/sync/) with delta updates on subsequent calls.
+- [Localization support](https://www.contentful.com/developers/docs/concepts/locales/) with locale fallback chains.
+- Automatic [link resolution](https://www.contentful.com/developers/docs/concepts/links/), configurable up to 10 levels deep.
+- Cross-space reference resolution, automatically linking entries and assets across multiple Contentful spaces.
+- Support for [Environments](https://www.contentful.com/developers/docs/concepts/multiple-environments/).
+- Synchronous, callback-based, and reactive (RxJava 3) methods of fetching content.
+- Unwrapping of `CDAEntry` responses into your own custom Java types via simple annotations.
+- [Rich Text](https://www.contentful.com/developers/docs/concepts/rich-text/) field decoding into a strongly typed node tree.
+- A companion [Rich Text renderer library](https://github.com/contentful/rich-text-renderer-java) for turning rich text into HTML or native Android output.
+
+## Getting started
-- Content retrieval through [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) and [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/).
-- [Synchronization](https://www.contentful.com/developers/docs/concepts/sync/)
-- [Localization support](https://www.contentful.com/developers/docs/concepts/locales/)
-- [Link resolution](https://www.contentful.com/developers/docs/concepts/links/)
-- Supports [Environments](https://www.contentful.com/developers/docs/concepts/multiple-environments/)
-- Synchronous and asynchrouns methods of fetching content
+In order to get started with the Contentful Java library you'll need not only to install it, but also to get credentials which will allow you to have access to your content in Contentful.
-Getting Started
-===============
+- [Requirements](#requirements)
+- [Installation](#installation)
+- [Your first request](#your-first-request)
+- [Authorization](#authorization)
+- [Accessing the Preview API](#accessing-the-preview-api)
-Setup
------
+### Requirements
-Install the Contentful dependency:
+| Requirement | Version |
+| --- | --- |
+| Java | 8 or higher |
+| Android | API 21+ |
+
+The SDK depends on OkHttp, Retrofit, Gson, and RxJava 3 for its networking, serialization, and reactive layers.
+
+### Installation
* _Maven_
+
```xml
com.contentful.java
java-sdk
- 10.6.0
+ 10.6.1
```
* _Gradle_
```groovy
-compile 'com.contentful.java:java-sdk:10.6.0'
+implementation 'com.contentful.java:java-sdk:10.6.1'
```
-This library requires Java 8 (or higher version) or Android 21.
+### Your first request
-Client Creation
----------------
-
-The `CDAClient` manages all interactions with the _Content Delivery API_.
+The `CDAClient` manages all interactions with the Content Delivery API:
```java
CDAClient client = CDAClient.builder()
@@ -100,28 +135,43 @@ CDAClient client = CDAClient.builder()
.build();
```
-The _Space_-id and _Access Token_ are retrived from the Contentful WebApp.
-
-First Request
--------------
-
-Fetching content is achieved by calling the `CDAClient.fetch()`-method. It fetches all _Resources_ from a Space. The following code fetches all _Entries_:
+Fetching content is achieved by calling the `.fetch()` method. It fetches all [Resources](https://www.contentful.com/developers/docs/references/content-delivery-api/#/introduction/common-resource-attributes) from a Space. The following code fetches all [Entries](https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries):
```java
-// Fetch entries
-CDAArray array =
+CDAArray array =
client
.fetch(CDAEntry.class)
.all();
```
-Usage
-=====
+### Authorization
+
+Grab credentials for your Contentful space by [navigating to the "APIs" section of the Contentful Web App](https://app.contentful.com/deeplink?link=api). The [Space](https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/spaces) ID and [Access Token](https://www.contentful.com/developers/docs/references/content-delivery-api/#/introduction/authentication) are retrieved from there.
+
+Delivery tokens only return published content, while preview tokens return the latest draft of your content. Never hard-code tokens into a shipping app; inject them from your build configuration or a secure store instead.
+
+### Accessing the Preview API
+
+The Content Delivery API only returns published Entries. The [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/) returns *all* Entries, even ones that aren't published yet:
+
+```java
+CDAClient client =
+ CDAClient.builder()
+ .setSpace("space-key-goes-here")
+ .setToken("access-token-goes-here")
+ .preview()
+ .build();
+```
+
+The [Preview Access Token](https://www.contentful.com/developers/docs/references/content-preview-api/#/introduction/preview-api-authentication) is exposed on the [Contentful Web App](https://app.contentful.com/deeplink?link=api).
+
+> Note: In Preview, Resources can be invalid since no validation is performed prior to publishing.
+
+## Using the SDK
-Filtering
----------
+### Filtering
-Filtering of Resources can be done by chaining method calls after the `.fetch()`. Using `.one()` and a Resource id retrieves only the specified Resource:
+Filtering of Resources can be done by chaining method calls after `.fetch()`. Using `.one()` and a Resource id retrieves only the specified Resource:
```java
CDAEntry entry =
@@ -130,10 +180,10 @@ CDAEntry entry =
.one("{entry-id-goes-here}");
```
-Fetching only Entries of a specific _Content Type_ is done by adding the `.withContentType({id})` call to the chain:
+Fetching only Entries of a specific [Content Type](https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/content-types) is done by adding the `.withContentType({id})` call to the chain:
```java
-CDAArray result =
+CDAArray result =
client
.fetch(CDAEntry.class)
.withContentType("{content-type-id-goes-here}")
@@ -141,7 +191,7 @@ CDAArray result =
.all();
```
-Finally fetching _Assets_ follows the same principles:
+Fetching [Assets](https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets) follows the same principles:
```java
// Fetch an Asset with a specific id
@@ -151,10 +201,9 @@ CDAAsset asset =
.one("{asset-id-goes-here}");
```
-Calls in Parallel
------------------
+### Calls in parallel
-All of the above examples are executed synchronously. In order to request asynchronously, provide a callback to `.all(…)` or `.one(…)`:
+All of the above examples are executed synchronously. To request content asynchronously, provide a callback to `.all(…)` or `.one(…)`:
```java
client
@@ -166,9 +215,9 @@ client
});
```
-> Note: The return value for any asynchronous methods is the Callback itself, making sure keeping a reference to it and clearing it according to its host lifecycle events is adviced.
+> Note: The return value for any asynchronous method is the callback itself. Keeping a reference to it and clearing it according to its host's lifecycle events is advised.
-If _RxJava_ is required instead, the `.observe()` method can be used to get an `Observable` instance:
+If [RxJava](https://github.com/ReactiveX/RxJava) is preferred instead, use `.observe()` to get an `Observable` instance:
```java
client
@@ -177,44 +226,39 @@ client
.subscribe(System.out::println);
```
-Paging
-------
+### Paging
-If more then _100_ Resources are in the Space, `.fetchAll()` only returns the first _100_. If more Resources are needed, specify the limit with the `.limit(X)` for example:
+If more than 100 Resources are in the Space, `.all()` only returns the first 100. If more Resources are needed, specify the limit with `.limit(X)`:
```java
-CDAArray result =
+CDAArray result =
client
.fetch(CDAEntry.class)
.limit(1000)
.all();
```
-The maximum number of Resources to be requested is _1000_.
-
-For more then _1000_ Resources `.skip(N)`, `.limit(L)` and `.orderBy(F)` methods are needed. By using `.skip(N)`, the first _N_ Resources are ignored and _L_, from `.limit(L)`, items are returned.
+The maximum number of Resources requestable in one call is 1000.
-To guarantee ordering, the use of the `.orderBy` method is required: It enforces the _Array_ to be in a predictable order.
-
-The following code is used to request all Entries:
+For more than 1000 Resources, `.skip(N)`, `.limit(L)`, and `.orderBy(F)` are needed together. `.skip(N)` ignores the first `N` Resources, and `L` items (from `.limit(L)`) are returned. To guarantee a stable order across paged requests, use `.orderBy(…)`:
```java
-// get the amount of Entries, without fetching the actual content
-final int amountOfResourcesInContentful =
+// Get the amount of Entries, without fetching the actual content.
+final int amountOfResourcesInContentful =
client
.fetch(CDAEntry.class)
.limit(0)
.all()
.total();
-// create storage for the Entries
+// Create storage for the Entries.
final List resources = new ArrayList(amountOfResourcesInContentful);
-// use page size, based on usecase
+// Use a page size based on your use case.
final int PAGE_SIZE = 2;
-// loop through all pages and store results
-for(int page = 0; page * PAGE_SIZE < amountOfResourcesInContentful; ++page) {
+// Loop through all pages and store results.
+for (int page = 0; page * PAGE_SIZE < amountOfResourcesInContentful; ++page) {
final CDAArray currentPagedItems = client
.fetch(CDAEntry.class)
.skip(page * PAGE_SIZE)
@@ -222,15 +266,14 @@ for(int page = 0; page * PAGE_SIZE < amountOfResourcesInContentful; ++page) {
.orderBy("sys.createdAt")
.all();
- // add to current list of Entries
resources.addAll(currentPagedItems.items());
}
```
-Using the `.reverseOrderBy()` method reverses the order:
+Use `.reverseOrderBy()` to reverse the order:
```java
-CDAArray result =
+CDAArray result =
client
.fetch(CDAEntry.class)
.limit(23)
@@ -238,31 +281,27 @@ CDAArray result =
.all();
```
-The above snippet will fetch the first _23_ Entries, sorted by creation date with the latest ones on top.
-
-[Sync](#sync) is used to fetch all entries in a single call and to get only changed Resources in following calls.
+The above snippet fetches the first 23 Entries, sorted by creation date with the latest ones on top.
-Includes
---------
+[Sync](#synchronization) is the recommended approach for fetching all entries in a single initial call and getting only changed Resources on subsequent calls.
-The library contains a feature called link resolution, which will take a link and resolve them. So there is no need to look through entry id's manually, a simple `.getField(…)` retrieves and entry directly, no need to use the link elements themselves.
+### Includes
-For this feature to work, the linked entry needs to be _published_ (see [preview](#preview)) and the include level needs to be set to include this entry. A level of `2` means, that the links of links are getting resolved. Entries of deeper levels contain an empty field if the link could not be resolved. Finding the id of the not resolved field can be achieved through comparing the `.rawFields` with the `.fields` property of an Entry.
+The library resolves links automatically: a simple `.getField(…)` retrieves a linked entry directly, without needing to look up the entry by id manually.
-In order to change the level of includes, the following snippet can be used as a guide:
+For link resolution to work, the linked entry needs to be *published* (see [Preview](#accessing-the-preview-api)), and the include level needs to be set to include it. A level of `2` means links-of-links are also resolved. Entries beyond the requested depth contain an empty field where the link could not be resolved; compare `.rawFields` with `.fields` to find the id of an unresolved field.
-```
+```java
CDAArray found = client.fetch(CDAEntry.class)
- .include(1) // maximum is 10
+ .include(1) // Maximum is 10.
.all();
```
-This only resolves the first level of includes. `10` is the maximum number of levels to be included and should be used sparingly, since this will bloat up the response by a lot.
+`10` is the maximum number of levels to include, and should be used sparingly since it can bloat the response significantly.
-Cross-Space References
-----------------------
+### Cross-space references
-In version 10.6.0 and later the library supports resolving cross-space references, which allows you to link content across multiple spaces. When cross-space tokens are configured, entries and assets from other spaces will be automatically included in the response's `includes` section and resolved by the library link resolution.
+The library supports resolving cross-space references, letting you link content across multiple Contentful spaces. When cross-space tokens are configured, entries and assets from other spaces are automatically included in the response's `includes` section and resolved by the library's link resolution.
To enable cross-space reference resolution, provide access tokens for the additional spaces:
@@ -277,26 +316,26 @@ CDAClient client = CDAClient.builder()
.setCrossSpaceTokens(crossSpaceTokens)
.build();
-// Cross-space references will now be automatically resolved
+// Cross-space references will now be automatically resolved.
CDAArray entries = client.fetch(CDAEntry.class)
.include(2)
.all();
```
-**Limitations:**
-- Maximum 20 extra spaces can be configured (21 total including the main space)
-- Only the first level of cross-space references is resolved (similar to `include=1` for cross-space)
-- The main space can still resolve up to 10 levels of includes
-- Cross-space errors are returned in the `CDAArray.getErrors()` method
+A few limits apply:
+
+- Maximum 20 extra spaces can be configured (21 total including the main space).
+- Only the first level of cross-space references is resolved (similar to `include=1` for cross-space).
+- The main space can still resolve up to 10 levels of includes.
+- Cross-space errors are returned via `CDAArray.getErrors()`.
For more information, see the [Contentful Resource Links documentation](https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/resource-links).
-Unwrapping
-----------
+### Unwrapping
-Unwrapping is the process of taking a `CDAEntry` and transforming it into custom types. The following code demonstrates the definition of a custom type:
+Unwrapping is the process of taking a `CDAEntry` and transforming it into your own custom types:
-```
+```java
import com.contentful.java.cda.TransformQuery.ContentfulEntryModel;
import com.contentful.java.cda.TransformQuery.ContentfulField;
@@ -319,107 +358,102 @@ public static class Cat {
}
```
-If this library should return a given response like the one above instead of a CDAEntry, the following code snippet will accomplish that:
+To have the library return your custom type instead of a `CDAEntry`:
-```
+```java
Cat happycat = client
.observeAndTransform(Cat.class)
.one("happycat")
.blockingFirst();
```
-In addition to returning the Content in a fashion flexible for various use-cases, this feature also uses the [select](#select) filter to only return the fields required, making the response smaller and more focused.
+Unwrapping also uses the [select](#select) filter under the hood to only return the fields required, making the response smaller and more focused.
> Notes:
-> * Specifying a `value` for the `@ContentfulField`-annotation , will use the value of the similarly called field id instead of the name of the custom field.
-> * A `locale` can be used to specify a given locale of this entry. If no locale is given, the default locale will be used.
-> * `@ContentfulSystemField` is used for CDAEntries attributes (`sys.id`, etc) to be inserted.
-> * If another type is wanted to be transformed, it should have `@ContentfulEntryModel`-annotation specified similarly as in `Cat`.
-> * **Limitation on Unwrapping**: Using Unwrapping does not currently allow direct access to the raw JSON for rich text fields, as the library automatically transforms fields into the custom model structure. For cases where raw JSON is needed:
-> * Use the `rawFields` map in `CDAEntry` to directly access the unprocessed JSON of any field, including rich text.
-> * Alternatively, make a direct HTTP request to the Contentful API to retrieve the full raw JSON response.
-
+> * Specifying a `value` for `@ContentfulField` uses the value as the field id instead of the name of the annotated field.
+> * A `locale` can be specified for a given field. If omitted, the default locale is used.
+> * `@ContentfulSystemField` is used to populate `CDAEntry` attributes (`sys.id`, etc).
+> * Any nested type must also be annotated with `@ContentfulEntryModel`, similar to `Cat` above.
+> * **Limitation:** Unwrapping does not currently allow direct access to the raw JSON for rich text fields, since the library automatically transforms fields into the custom model structure. Use the `rawFields` map on `CDAEntry` to access the unprocessed JSON of any field, including rich text, or make a direct HTTP request to the Contentful API for the full raw JSON response.
-Select
-------
+### Select
-The amount of data returned by the API can be reduced by using the `.select()` method on a query. With this, Contentful only returns the selected fields. The library enforces that the `sys` fields (`.getAttribute()` on an Entry) will always be returned, since it is used for the proper functioning of the library.
+The amount of data returned by the API can be reduced with `.select()`. The library always requests the `sys` fields (`.getAttribute()` on an Entry), since they're required for the library to function correctly:
-If reducing the payload size is wanted, the following snippet can explain how to accomplish that
-
-```
+```java
CDAArray found = client.fetch(CDAEntry.class)
- .withContentType("cat");
+ .withContentType("cat")
.select("fields.name");
```
-This snippet makes sure that the entries of type `cat` are only containing its `name` field. All other fields will be `null` or its respective default value.
-> Note: The content type has to be added through `.withContentType(…)` otherwise an error ensues.
+This ensures entries of type `cat` only contain their `name` field — all other fields are `null` or their default value.
+
+> Note: The content type must be added through `.withContentType(…)`, otherwise an error is thrown.
-Preview
--------
+### Synchronization
-The _Content Delivery API_ only returns _published_ Entries. The _Content Preview API_ will return _all_ Entries, even not published ones:
+Fetching all Resources initially, and only changes on subsequent calls, is accomplished with the `.sync()` methods:
```java
-CDAClient client =
- CDAClient.builder()
- .setSpace("space-key-goes-here")
- .setToken("access-token-goes-here")
- .preview()
- .build();
+SynchronizedSpace space = client.sync().fetch();
```
-The _Preview Access Token_ is exposed on the [Contentful Web App](https://app.contentful.com/deeplink?link=api).
+The `SynchronizedSpace` contains all published Resources. If `.preview()` (see [Preview](#accessing-the-preview-api)) is used, it also contains unpublished Resources.
-> Note: In Preview, Resources can be invalid since no validation is performed prior to publishing.
+To fetch changes later, call `.sync()` again, passing the previous `SynchronizedSpace` as a parameter:
+
+```java
+SynchronizedSpace later = client.sync(space).fetch();
+```
-Sync
-----
+If an Entry is deleted, its id is returned in `SynchronizedSpace.deletedEntries()`. The same is true for deleted Assets via `SynchronizedSpace.deletedAssets()`.
-Fetching all Resources and retrieving only changes on subsequent calls is accomplished by using the `.sync()`-methods:
+### Rich text
+
+Rich text fields decode into a `CDARichDocument`, the base of all rich text nodes in the SDK:
```java
-SynchronizedSpace space = client.sync().fetch();
+final CDARichDocument node = entry.getField(FIELD_ID);
```
-The _SynchronizedSpace_ contains _all_ _published_ Resources. If `.preview()` ([see Preview](#preview)) is used, it also contains all unpublished Resources.
-
-If changes are to be fetched later, calling `sync()` again using the given SynchronizedSpace as a parameter is needed:
+If your data comes from an external tool (for example a JavaScript library), you can build a `CDARichDocument` from plain JSON — useful when the content wasn't fetched directly through this library. Using GSON for JSON processing:
```java
-SynchronizedSpace later = client.sync(space).fetch();
+private final Gson gson = new Gson();
+Type type = new TypeToken