Skip to content

Commit e7a0c41

Browse files
Add rich text (#178)
map out all rich text types (https://www.contentful.com/developers/docs/concepts/rich-text/)
1 parent 3a0bd22 commit e7a0c41

File tree

93 files changed

+3464
-485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3464
-485
lines changed

.buildscript/deploy_snapshot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ else
2626
fi
2727

2828
echo "Deploying snapshot to jitpack ..."
29-
curl https://jitpack.io/com/github/contentful/contentful.java/${TRAVIS_BRANCH}-SNAPSHOT
29+
curl --verbose --location "https://jitpack.io/com/github/contentful/contentful.java/${TRAVIS_BRANCH}-SNAPSHOT/"
3030
echo "Snapshot deployed to jitpack!"
3131

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ language: java
22
sudo: false
33

44
jdk:
5-
- openjdk7
65
- openjdk8
76
- oraclejdk8
7+
- oraclejdk9
88

99
script:
1010
- mvn jacoco:prepare-agent test jacoco:report

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## Version [10.2.0] - (2018-11-12)
6+
- Add [rich text](https://www.contentful.com/developers/docs/concepts/rich-text/) to entry types.
7+
58
## Version [10.1.0] - (2018-05-22)
69
- Add `png8` image option for returning images in png with up to 256 colours.
710
- Make `sync` environment aware.
@@ -221,8 +224,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
221224
## Version 1.0.0 - 2014-08-13
222225
Initial release.
223226

224-
[unreleased]: https://github.com/contentful/contentful.java/compare/java-sdk-10.1.0...HEAD
225-
[10.0.0]: https://github.com/contentful/contentful.java/compare/java-sdk-10.0.0...java-sdk-10.1.0
227+
[unreleased]: https://github.com/contentful/contentful.java/compare/java-sdk-10.2.0...HEAD
228+
[10.2.0]: https://github.com/contentful/contentful.java/compare/java-sdk-10.1.0...java-sdk-10.2.0
229+
[10.1.0]: https://github.com/contentful/contentful.java/compare/java-sdk-10.0.0...java-sdk-10.1.0
226230
[10.0.0]: https://github.com/contentful/contentful.java/compare/java-sdk-9.1.1...java-sdk-10.0.0
227231
[9.1.1]: https://github.com/contentful/contentful.java/compare/java-sdk-9.1.0...java-sdk-9.1.1
228232
[9.1.0]: https://github.com/contentful/contentful.java/compare/java-sdk-9.0.1...java-sdk-9.1.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Install the Contentful dependency:
8686
compile 'com.contentful.java:java-sdk:10.0.0'
8787
```
8888

89-
This SDK requires Java 7 (or higher version) or Android 5.
89+
This SDK requires Java 8 (or higher version) or Android 5.
9090

9191
Client Creation
9292
---------------

checkstyle.xml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
<!-- Checks for common coding problems -->
9898
<!-- See http://checkstyle.sf.net/config_coding.html -->
9999
<module name="CovariantEquals"/>
100-
<module name="DoubleCheckedLocking"/>
101100
<module name="EmptyStatement"/>
102101
<module name="EqualsAvoidNull"/>
103102
<module name="EqualsHashCode"/>
@@ -107,10 +106,6 @@
107106
<property name="ignoreNumbers" value="-1,0,1,2,10,100,255,16777215"/>
108107
</module>
109108
<module name="MissingSwitchDefault"/>
110-
<module name="RedundantThrows">
111-
<property name="allowUnchecked" value="true"/>
112-
<property name="allowSubclasses" value="true"/>
113-
</module>
114109
<module name="SimplifyBooleanExpression"/>
115110
<module name="SimplifyBooleanReturn"/>
116111

@@ -126,13 +121,12 @@
126121
<module name="TodoComment"/>
127122
<module name="UpperEll"/>
128123

129-
<module name="FileContentsHolder"/>
130-
</module>
131124

132-
<!-- Disable checkstyle for to long lines of code -->
133-
<module name="SuppressionCommentFilter">
134-
<property name="offCommentFormat" value="BEGIN TO LONG CODE LINES"/>
135-
<property name="onCommentFormat" value="END TO LONG CODE LINES"/>
136-
<property name="checkFormat" value="LineLengthCheck"/>
125+
<!-- Disable checkstyle for to long lines of code -->
126+
<module name="SuppressionCommentFilter">
127+
<property name="offCommentFormat" value="BEGIN TO LONG CODE LINES"/>
128+
<property name="onCommentFormat" value="END TO LONG CODE LINES"/>
129+
<property name="checkFormat" value="LineLengthCheck"/>
130+
</module>
137131
</module>
138132
</module>

pom.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>com.contentful.java</groupId>
55
<artifactId>java-sdk</artifactId>
6-
<version>10.1.1-SNAPSHOT</version>
6+
<version>10.2.0-SNAPSHOT</version>
77
<packaging>jar</packaging>
88

99
<name>${project.groupId}:${project.artifactId}</name>
@@ -45,7 +45,7 @@
4545
<project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>
4646

4747
<!-- Compilation -->
48-
<java.version>1.6</java.version>
48+
<java.version>1.8</java.version>
4949

5050
<!-- Dependencies -->
5151
<retrofit.version>2.3.0</retrofit.version>
@@ -220,8 +220,15 @@
220220
<plugin>
221221
<groupId>org.apache.maven.plugins</groupId>
222222
<artifactId>maven-checkstyle-plugin</artifactId>
223-
<version>2.9.1</version>
224-
<configuration>
223+
<version>3.0.0</version>
224+
<dependencies>
225+
<dependency>
226+
<groupId>com.puppycrawl.tools</groupId>
227+
<artifactId>checkstyle</artifactId>
228+
<version>8.12</version>
229+
</dependency>
230+
</dependencies>
231+
<configuration>
225232
<failsOnError>true</failsOnError>
226233
<configLocation>checkstyle.xml</configLocation>
227234
<consoleOutput>true</consoleOutput>

src/main/java/com/contentful/java/cda/AbsQuery.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public abstract class AbsQuery<
3535

3636
final CDAClient client;
3737

38-
final Map<String, String> params = new HashMap<String, String>();
38+
final Map<String, String> params = new HashMap<>();
3939

4040
AbsQuery(Class<Resource> type, CDAClient client) {
4141
this.type = type;
@@ -357,7 +357,7 @@ public Query reverseOrderBy(String key) {
357357
* Limits the amount of elements to a given number.
358358
* <p>
359359
* If more then the number given elements are present, you can use {@link #skip(int)} and
360-
* {@link #limit(int)} for pagination.
360+
* {@see #limit(int)} for pagination.
361361
*
362362
* @param limit a non negative number less than 1001 to include elements.
363363
* @return the calling query for chaining.

src/main/java/com/contentful/java/cda/ArrayResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
*
99
* @see CDAResource
1010
*/
11-
abstract class ArrayResource extends CDAResource {
11+
public abstract class ArrayResource extends CDAResource {
12+
private static final long serialVersionUID = -2702554830040250962L;
1213
List<CDAResource> items;
1314

1415
Map<String, CDAAsset> assets;

src/main/java/com/contentful/java/cda/CDAArray.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Collection of CDA resources.
99
*/
1010
public class CDAArray extends ArrayResource {
11+
private static final long serialVersionUID = 6596224363025698245L;
1112
int total;
1213

1314
int skip;

src/main/java/com/contentful/java/cda/CDAAsset.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*/
1111
public class CDAAsset extends LocalizedResource {
1212

13+
private static final long serialVersionUID = -4645571481643616657L;
14+
1315
/**
1416
* @return title of this asset.
1517
*/
@@ -53,7 +55,7 @@ public String urlForImageWith(ImageOption... options) {
5355
}
5456

5557
final Map<String, ImageOption> mappedOptions
56-
= new LinkedHashMap<String, ImageOption>(options.length);
58+
= new LinkedHashMap<>(options.length);
5759

5860
for (final ImageOption option : options) {
5961
mappedOptions.put(option.getOperation(), option);

src/main/java/com/contentful/java/cda/CDAClient.java

Lines changed: 33 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import io.reactivex.functions.Function;
3232
import okhttp3.Call;
3333
import okhttp3.OkHttpClient;
34-
import retrofit2.Response;
3534
import retrofit2.Retrofit;
3635
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
3736
import retrofit2.converter.gson.GsonConverterFactory;
@@ -126,7 +125,7 @@ private static CDAService createService(Builder clientBuilder) {
126125
* @see #fetchSpace()
127126
*/
128127
public <T extends CDAResource> FetchQuery<T> fetch(Class<T> type) {
129-
return new FetchQuery<T>(type, this);
128+
return new FetchQuery<>(type, this);
130129
}
131130

132131
/**
@@ -140,7 +139,7 @@ public <T extends CDAResource> FetchQuery<T> fetch(Class<T> type) {
140139
* @see #observeSpace()
141140
*/
142141
public <T extends CDAResource> ObserveQuery<T> observe(Class<T> type) {
143-
return new ObserveQuery<T>(type, this);
142+
return new ObserveQuery<>(type, this);
144143
}
145144

146145
/**
@@ -223,7 +222,7 @@ public Flowable<Integer> observeContentTypeCachePopulation(final int limit) {
223222
.all()
224223
.map(
225224
new Function<CDAArray, CDAArray>() {
226-
@Override public CDAArray apply(CDAArray array) throws Exception {
225+
@Override public CDAArray apply(CDAArray array) {
227226
if (array.skip() + array.limit() < array.total()) {
228227
return nextPage(array);
229228
} else {
@@ -250,20 +249,18 @@ private CDAArray nextPage(CDAArray array) {
250249
}
251250
)
252251
.map(
253-
new Function<CDAArray, Integer>() {
254-
@Override public Integer apply(CDAArray array) throws Exception {
255-
for (CDAResource resource : array.items) {
256-
if (resource instanceof CDAContentType) {
257-
cache.types().put(resource.id(), (CDAContentType) resource);
258-
} else {
259-
throw new IllegalStateException(
260-
"Requesting a list of content types should not return "
261-
+ "any other type.");
262-
}
252+
array -> {
253+
for (CDAResource resource : array.items) {
254+
if (resource instanceof CDAContentType) {
255+
cache.types().put(resource.id(), (CDAContentType) resource);
256+
} else {
257+
throw new IllegalStateException(
258+
"Requesting a list of content types should not return "
259+
+ "any other type.");
263260
}
264-
265-
return array.total;
266261
}
262+
263+
return array.total;
267264
}
268265
);
269266
}
@@ -363,40 +360,26 @@ public <C extends CDACallback<CDASpace>> C fetchSpace(C callback) {
363360
* @return an {@link Flowable} that fetches the space for this client.
364361
*/
365362
public Flowable<CDASpace> observeSpace() {
366-
return service.space(spaceId).map(new Function<Response<? extends CDASpace>, CDASpace>() {
367-
@Override public CDASpace apply(Response<? extends CDASpace> response) throws Exception {
368-
return fromResponse(response);
369-
}
370-
});
363+
return service.space(spaceId).map(ResourceFactory::fromResponse);
371364
}
372365

373366
/**
374367
* Caching
375368
*/
376369
Flowable<Cache> cacheAll(final boolean invalidate) {
377370
return cacheLocales(invalidate)
378-
.flatMap(new Function<List<CDALocale>, Flowable<Map<String, CDAContentType>>>() {
379-
@Override public Flowable<Map<String, CDAContentType>> apply(List<CDALocale> locales) {
380-
return cacheTypes(invalidate);
381-
}
382-
})
383-
.map(new Function<Map<String, CDAContentType>, Cache>() {
384-
@Override public Cache apply(Map<String, CDAContentType> stringCDAContentTypeMap) {
385-
return cache;
386-
}
387-
});
371+
.flatMap(locales -> cacheTypes(invalidate))
372+
.map(stringCDAContentTypeMap -> cache);
388373
}
389374

390375
Flowable<List<CDALocale>> cacheLocales(boolean invalidate) {
391376
List<CDALocale> locales = invalidate ? null : cache.locales();
392377
if (locales == null) {
393-
return service.array(spaceId, environmentId, PATH_LOCALES, new HashMap<String, String>())
394-
.map(new Function<Response<CDAArray>, List<CDALocale>>() {
395-
@Override public List<CDALocale> apply(Response<CDAArray> localesResponse) {
396-
final List<CDALocale> locales = fromArrayToItems(fromResponse(localesResponse));
397-
cache.setLocales(locales);
398-
return locales;
399-
}
378+
return service.array(spaceId, environmentId, PATH_LOCALES, new HashMap<>())
379+
.map(localesResponse -> {
380+
final List<CDALocale> locales1 = fromArrayToItems(fromResponse(localesResponse));
381+
cache.setLocales(locales1);
382+
return locales1;
400383
});
401384
}
402385
return Flowable.just(locales);
@@ -409,18 +392,16 @@ Flowable<Map<String, CDAContentType>> cacheTypes(boolean invalidate) {
409392
spaceId,
410393
environmentId,
411394
PATH_CONTENT_TYPES,
412-
new HashMap<String, String>()
395+
new HashMap<>()
413396
).map(
414-
new Function<Response<CDAArray>, Map<String, CDAContentType>>() {
415-
@Override public Map<String, CDAContentType> apply(Response<CDAArray> arrayResponse) {
416-
CDAArray array = ResourceFactory.array(arrayResponse, CDAClient.this);
417-
Map<String, CDAContentType> tmp = new ConcurrentHashMap<String, CDAContentType>();
418-
for (CDAResource resource : array.items()) {
419-
tmp.put(resource.id(), (CDAContentType) resource);
420-
}
421-
cache.setTypes(tmp);
422-
return tmp;
397+
arrayResponse -> {
398+
CDAArray array = ResourceFactory.array(arrayResponse, CDAClient.this);
399+
Map<String, CDAContentType> tmp = new ConcurrentHashMap<>();
400+
for (CDAResource resource : array.items()) {
401+
tmp.put(resource.id(), (CDAContentType) resource);
423402
}
403+
cache.setTypes(tmp);
404+
return tmp;
424405
});
425406
}
426407
return Flowable.just(types);
@@ -432,13 +413,11 @@ Flowable<CDAContentType> cacheTypeWithId(String id) {
432413
return observe(CDAContentType.class)
433414
.one(id)
434415
.map(
435-
new Function<CDAContentType, CDAContentType>() {
436-
@Override public CDAContentType apply(CDAContentType resource) {
437-
if (resource != null) {
438-
cache.types().put(resource.id(), resource);
439-
}
440-
return resource;
416+
resource -> {
417+
if (resource != null) {
418+
cache.types().put(resource.id(), resource);
441419
}
420+
return resource;
442421
}
443422
);
444423
}

src/main/java/com/contentful/java/cda/CDAContentType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Represents a single content type.
77
*/
88
public class CDAContentType extends CDAResource {
9+
private static final long serialVersionUID = 7901798878659781364L;
910
List<CDAField> fields;
1011

1112
String name;

src/main/java/com/contentful/java/cda/CDAContentTypeNotFoundException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*/
1111
public class CDAContentTypeNotFoundException extends RuntimeException {
1212

13+
private static final long serialVersionUID = -5839900656195732862L;
14+
1315
/**
1416
* Create a new exception.
1517
*

src/main/java/com/contentful/java/cda/CDAEntry.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* The class represents a basic entry in the space.
55
*/
66
public class CDAEntry extends LocalizedResource {
7+
private static final long serialVersionUID = 5902790363045498307L;
78
private CDAContentType contentType;
89

910
/**

src/main/java/com/contentful/java/cda/CDAField.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/** Represents a single content type field. */
88
public class CDAField implements Serializable {
9+
private static final long serialVersionUID = -2852530837647669035L;
910
String name;
1011

1112
String id;

src/main/java/com/contentful/java/cda/CDAHttpException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* This class will represent known Contentful exceptions
1717
*/
1818
public class CDAHttpException extends RuntimeException {
19+
private static final long serialVersionUID = 637581021148308658L;
1920
private final Request request;
2021
private final Response response;
2122
private final String responseBody;

src/main/java/com/contentful/java/cda/CDALocale.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Represents a single locale.
77
*/
88
public class CDALocale extends CDAResource {
9+
private static final long serialVersionUID = -5710267672379169621L;
910
String code;
1011

1112
String name;

src/main/java/com/contentful/java/cda/CDAResource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* for CDAContentType, CDASpace and, indirectly, for CDAEntry.
1313
*/
1414
public abstract class CDAResource implements Serializable {
15+
private static final long serialVersionUID = -160701290783423915L;
1516
@SerializedName("sys")
1617
Map<String, Object> attrs;
1718

0 commit comments

Comments
 (0)