Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ Install the Contentful dependency:
<dependency>
<groupId>com.contentful.java</groupId>
<artifactId>java-sdk</artifactId>
<version>10.5.21</version>
<version>10.5.22</version>
</dependency>
```

* _Gradle_

```groovy
compile 'com.contentful.java:java-sdk:10.5.21'
compile 'com.contentful.java:java-sdk:10.5.22'
```

This library requires Java 8 (or higher version) or Android 21.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.contentful.java</groupId>
<artifactId>java-sdk</artifactId>
<version>10.5.22-SNAPSHOT</version>
<version>10.5.23-SNAPSHOT</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -191,7 +191,7 @@
<id>simple-command</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
Comment thread
whitelisab marked this conversation as resolved.
<goal>single</goal>
</goals>
</execution>
</executions>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/contentful/java/cda/CDAEntry.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.contentful.java.cda;

import com.google.gson.annotations.SerializedName;

/**
* The class represents a basic entry in the space.
*/
public class CDAEntry extends LocalizedResource {
private static final long serialVersionUID = 5902790363045498307L;
protected CDAContentType contentType;
@SerializedName("metadata")
private CDAMetadata metadata;

/**
Expand All @@ -30,6 +33,14 @@ protected void setContentType(CDAContentType contentType) {
this.contentType = contentType;
}

public CDAMetadata getMetadata() {
return metadata;
}

public void setMetadata(CDAMetadata metadata) {
this.metadata = metadata;
}

/**
* Create a human readable string of this object.
* @return a string, containing the id of this content type.
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/com/contentful/java/cda/CDAMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

import java.io.Serializable;
import java.util.List;

public class CDAMetadata implements Serializable {
private static final long serialVersionUID = -2852530837647649035L;
private List<CDATag> tags;
private List<CDATaxonomyConcept> concepts;

public List<CDATag> getTags() {
return tags;
}

public void setTags(List<CDATag> tags) {
Comment thread
whitelisab marked this conversation as resolved.
this.tags = tags;
public List<CDATaxonomyConcept> getConcepts() {
return concepts;
}

public void setConcepts(List<CDATaxonomyConcept> concepts) {
this.concepts = concepts;
}
List<CDATag> tags;

@Override
public String toString() {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/contentful/java/cda/CDATaxonomyConcept.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.contentful.java.cda;


public class CDATaxonomyConcept extends CDAResource {
@Override
public String toString() {
return "CDATaxonomyConcept{"
+ "attrs=" + attrs
+ '}';
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/contentful/java/cda/CDAType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public enum CDAType {
ENTRY,
LOCALE,
SPACE,
TAG
TAG,
TAXONOMYCONCEPT,
}
2 changes: 2 additions & 0 deletions src/main/java/com/contentful/java/cda/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ class Constants {

static final String PATH_TAGS = "tags";

static final String PATH_TAXONOMY_CONCEPTS = "taxonomy/concepts";

static final String DEFAULT_ENVIRONMENT = "master";
}
15 changes: 11 additions & 4 deletions src/main/java/com/contentful/java/cda/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static com.contentful.java.cda.CDAType.SPACE;
import static com.contentful.java.cda.CDAType.ENTRY;
import static com.contentful.java.cda.CDAType.CONTENTTYPE;
import static com.contentful.java.cda.CDAType.TAXONOMYCONCEPT;

final class Util {
private Util() {
Expand Down Expand Up @@ -46,25 +47,29 @@ static String resourcePath(Class<?> clazz) {
return Constants.PATH_LOCALES;
} else if (CDATag.class.equals(clazz)) {
return Constants.PATH_TAGS;
} else if (CDATaxonomyConcept.class.equals(clazz)) {
return Constants.PATH_TAXONOMY_CONCEPTS;
}
throw new IllegalArgumentException("Invalid type specified: " + clazz.getName());
}

static Class<? extends CDAResource> classForType(CDAType type) {
if (CDAType.ASSET.equals(type)) {
if (ASSET.equals(type)) {
return CDAAsset.class;
} else if (CDAType.CONTENTTYPE.equals(type)) {
} else if (CONTENTTYPE.equals(type)) {
return CDAContentType.class;
} else if (CDAType.ENTRY.equals(type)) {
} else if (ENTRY.equals(type)) {
return CDAEntry.class;
} else if (CDAType.SPACE.equals(type)) {
} else if (SPACE.equals(type)) {
return CDASpace.class;
} else if (LOCALE.equals(type)) {
return CDALocale.class;
} else if (DELETEDASSET.equals(type) || DELETEDENTRY.equals(type)) {
return DeletedResource.class;
} else if (TAG.equals(type)) {
return CDATag.class;
} else if (TAXONOMYCONCEPT.equals(type)) {
return CDATaxonomyConcept.class;
}
throw new IllegalArgumentException("Invalid type provided: " + type);
}
Expand All @@ -82,6 +87,8 @@ static CDAType typeForClass(Class<? extends CDAResource> clazz) {
return LOCALE;
} else if (CDATag.class.equals(clazz)) {
return TAG;
} else if (CDATaxonomyConcept.class.equals(clazz)) {
return TAXONOMYCONCEPT;
}
throw new IllegalArgumentException("Invalid class provided: " + clazz.getName());
}
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/com/contentful/java/cda/EntryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import java.util.concurrent.TimeUnit;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.ArrayList;

public class EntryTest extends BaseTest {
@Test(expected = CDAResourceNotFoundException.class)
Expand Down Expand Up @@ -97,6 +101,17 @@ public void entryContentType() {
assertThat(entry.contentType()).isNotNull();
}

@Test
@Enqueue("demo/entries.json")
public void entryTaxonomy() {
CDAEntry entry = client.fetch(CDAEntry.class).one("ge1xHyH3QOWucKWCCAgIG");
assertThat(entry.contentType()).isNotNull();
assertNotNull(entry.getMetadata());
assertNotNull(entry.getMetadata().getConcepts());
assertEquals(1, entry.getMetadata().getConcepts().size());
}


@Test
@Enqueue("demo/entries_nyancat.json")
public void fetchEntry() {
Expand Down
Loading