Skip to content

Commit 0502fe0

Browse files
author
Tom Reznik
committed
Revert skipLinks() for CDAClient
1 parent 7b45316 commit 0502fe0

File tree

4 files changed

+5
-49
lines changed

4 files changed

+5
-49
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,10 @@ public T call() throws Exception {
9494
}
9595
}
9696

97-
if (!context.skipLinks) {
98-
// Iterate through all entries and attempt to resolve contained links.
99-
for (CDAResource resource : entries.values()) {
100-
if (resource instanceof ResourceWithMap) {
101-
resolveResourceLinks((ResourceWithMap) resource, assets, entries);
102-
}
97+
// Iterate through all entries and attempt to resolve contained links.
98+
for (CDAResource resource : entries.values()) {
99+
if (resource instanceof ResourceWithMap) {
100+
resolveResourceLinks((ResourceWithMap) resource, assets, entries);
103101
}
104102
}
105103

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ public class CDAClient {
5656
final Gson gson;
5757
final SpaceWrapper spaceWrapper;
5858
final Executor callbackExecutor;
59-
final boolean skipLinks;
59+
final boolean nullifyUnresolved;
6060

6161
// Modules
6262
final ModuleAssets moduleAssets;
6363
final ModuleContentTypes moduleContentTypes;
6464
final ModuleEntries moduleEntries;
6565
final ModuleSpaces moduleSpaces;
6666
final ModuleSync moduleSync;
67-
final boolean nullifyUnresolved;
6867

6968
private CDAClient(Builder builder) {
7069
if (builder.accessToken == null) {
@@ -84,7 +83,6 @@ private CDAClient(Builder builder) {
8483
this.callbackExecutor = createCallbackExecutor(builder);
8584
this.gson = createGson();
8685
this.service = createRetrofitService(builder);
87-
this.skipLinks = builder.skipLinks;
8886
this.nullifyUnresolved = builder.nullifyUnresolved;
8987

9088
ClientContext context = createContext();
@@ -103,7 +101,6 @@ private ClientContext createContext() {
103101
.setGson(gson)
104102
.setSpaceWrapper(spaceWrapper)
105103
.setCustomTypesMap(classMap)
106-
.setSkipLinks(skipLinks)
107104
.setNullifyUnresolved(nullifyUnresolved)
108105
.build();
109106
}
@@ -286,7 +283,6 @@ public static class Builder {
286283
Map<String, Class<?>> classMap;
287284
boolean secure;
288285
boolean nullifyUnresolved;
289-
boolean skipLinks;
290286

291287
private Builder() {
292288
// Defaults
@@ -448,16 +444,6 @@ public Builder preview() {
448444
return setEndpoint(Constants.ENDPOINT_PREVIEW);
449445
}
450446

451-
/**
452-
* Sets the behavior of this client to never resolve any links.
453-
*
454-
* @return this {@code Builder} instance
455-
*/
456-
public Builder skipLinks() {
457-
this.skipLinks = true;
458-
return this;
459-
}
460-
461447
/**
462448
* By default, unresolved links will point to a {@code Map} instance containing all the links
463449
* details. This changes the default behaviour to remove any unresolved links.

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ final class ClientContext {
3030
final Gson gson;
3131
final SpaceWrapper spaceWrapper;
3232
final Map<String, Class<?>> customTypesMap;
33-
final boolean skipLinks;
3433
final boolean nullifyUnresolved;
3534

3635
private ClientContext() {
@@ -44,7 +43,6 @@ public ClientContext(Builder builder) {
4443
this.gson = builder.gson;
4544
this.spaceWrapper = builder.spaceWrapper;
4645
this.customTypesMap = builder.customTypesMap;
47-
this.skipLinks = builder.skipLinks;
4846
this.nullifyUnresolved = builder.nullifyUnresolved;
4947
}
5048

@@ -59,7 +57,6 @@ static class Builder {
5957
private Gson gson;
6058
private SpaceWrapper spaceWrapper;
6159
private Map<String, Class<?>> customTypesMap;
62-
private boolean skipLinks;
6360
private boolean nullifyUnresolved;
6461

6562
private Builder() {
@@ -95,11 +92,6 @@ public Builder setCustomTypesMap(Map<String, Class<?>> customTypesMap) {
9592
return this;
9693
}
9794

98-
public Builder setSkipLinks(boolean skipLinks) {
99-
this.skipLinks = skipLinks;
100-
return this;
101-
}
102-
10395
public Builder setNullifyUnresolved(boolean nullifyUnresolved) {
10496
this.nullifyUnresolved = nullifyUnresolved;
10597
return this;

src/test/kotlin/com/contentful/java/cda/ClientTests.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,6 @@ import org.junit.Test as test
3838
* Client Tests.
3939
*/
4040
class ClientTests : BaseTest() {
41-
test fun testDontResolveLinks() {
42-
enqueue("space_fetch_response.json")
43-
enqueue("entry_fetch_all_response.json")
44-
45-
val cli = CDAClient.builder()
46-
.setAccessToken("token")
47-
.setSpaceKey("spaceid")
48-
.setEndpoint(getServerUrl())
49-
.setLogLevel(RestAdapter.LogLevel.FULL)
50-
.skipLinks()
51-
.noSSL()
52-
.build()
53-
54-
val array = cli.entries().fetchAll()
55-
var jake = array.getItems()[0] as? CDAEntry
56-
assertNotNull(jake)
57-
assertEquals("Jake", jake!!.getFields()["name"])
58-
assertFalse(jake!!.getFields()["image"] is CDAResource)
59-
}
60-
6141
test fun testCancelledCallback() {
6242
enqueue("space_fetch_response.json")
6343

0 commit comments

Comments
 (0)