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
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# CHANGELOG

## Version 1.6.0
###### Date: 05-APR-2021
- **Query** : query.includeEmbeddedItems() method support added
- **Entry** : entry.includeEmbeddedItems() method support added

------------------------------------------------

## Version 1.5.7
###### Date: 20-Feb-2021
Document updated

#23 Fixed Issue: Querying content with `null` field
• Query: query content by specifying fields as null
------------------------------------------------

## Version 1.5.6
###### Date: 27-Jan-2021
Expand All @@ -14,6 +20,8 @@ Document updated
New Features:
• None

------------------------------------------------

## Version 1.5.5
###### Date: 22-Jan-2021
Bug fix: Error contains information like
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2012 - 2020 Contentstack
Copyright (c) 2012 - 2021 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ To use the Contentstack Java SDK to your existing project, perform the steps giv
<dependency>
<groupId>com.contentstack.sdk</groupId>
<artifactId>java</artifactId>
<version>1.5.7</version>
<version>1.6.0</version>
</dependency>
```

2. **Gradle**
```java
implementation 'com.contentstack.sdk:java:1.5.7'
implementation 'com.contentstack.sdk:java:1.6.0'
```

### Key Concepts for using Contentstack
Expand Down
33 changes: 10 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.contentstack.sdk</groupId>
<artifactId>java</artifactId>
<version>1.5.7</version>
<version>1.6.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>contentstack-java</name>
<description>Java SDK for Contentstack Content Delivery API, Contentstack is a headless CMS with an API-first approach
Expand Down Expand Up @@ -82,17 +82,26 @@


<dependencies>

<dependency>
<groupId>com.contentstack.sdk</groupId>
<artifactId>utils</artifactId>
<version>1.0.0</version>
</dependency>

<dependency>
<groupId>io.github.cdimascio</groupId>
<artifactId>java-dotenv</artifactId>
<version>5.2.2</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
Expand All @@ -116,7 +125,6 @@

<build>
<plugins>

<!--
# Run tests and generate .xml reports
mvn test
Expand All @@ -126,7 +134,6 @@
# time-consuming stuff
mvn surefire-report:report site -DgenerateReports=false
-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
Expand All @@ -140,11 +147,6 @@
</execution>
</executions>
</plugin>

<!--
The Source Plugin creates a jar archive of the source files of
the current project. The jar file is, by default, created in the project's target directory.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand All @@ -158,8 +160,6 @@
</execution>
</executions>
</plugin>

<!--The Javadoc Plugin uses the Javadoc tool to generate javadocs for the specified project-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand All @@ -184,11 +184,6 @@
</execution>
</executions>
</plugin>

<!--
The Site Plugin is used to generate a site for the project.
The generated site also includes the project's reports that were configured in the POM.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
Expand All @@ -214,7 +209,6 @@
</execution>
</executions>
</plugin>

<!--
Sometimes when you may need to compile a certain project to a different
version than what you are currently using. The javac can accept such command
Expand All @@ -232,10 +226,7 @@
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>

</plugin>

<!--Provides support to access staging functionality in a remote Nexus Professional server.-->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand All @@ -247,7 +238,6 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>

<!--
This plugin is used to release a project with Maven, saving a lot of repetitive, manual work.
Releasing a project is made in two steps: prepare and perform.
Expand All @@ -263,8 +253,6 @@
<goals>deploy</goals>
</configuration>
</plugin>


<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand All @@ -281,7 +269,6 @@
<goals>
<goal>report</goal>
</goals>

</execution>
</executions>
</plugin>
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/contentstack/sdk/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -1333,4 +1333,19 @@ public Entry includeFallback(){
return this;
}


/**
* includeEmbeddedItems instance of Entry
* Include Embedded Objects (Entries and Assets) along with entry/entries details.<br>
* Stack stack = Contentstack.stack( "ApiKey", "deliveryToken", "environment");
* final Entry entry = stack.contentType("user").entry("entryUid");
* entry = entry.includeEmbeddedObjects()
* entry.fetch()
* @return {@link Entry}
*/
public Entry includeEmbeddedItems() {
otherPostJSON.put("include_embedded_items[]", "BASE");
return this;
}

}
12 changes: 12 additions & 0 deletions src/main/java/com/contentstack/sdk/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,18 @@ public Query includeFallback() {
return this;
}

/**
* includeEmbeddedItems instance of Query
* Include Embedded Objects (Entries and Assets) along with entry/entries details.<br>
* Stack stack = Contentstack.stack( "ApiKey", "deliveryToken", "environment");
* final Query query = stack.contentType("user").query();
* query = query.includeEmbeddedObjects()
* @return {@link Query}
*/
public Query includeEmbeddedItems() {
urlQueries.put("include_embedded_items[]", "BASE");
return this;
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class CSAppConstants {

public static final String SDK_VERSION = "1.5.7";
public static final String SDK_VERSION = "1.6.0";

public static enum RequestMethod
{
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/com/contentstack/sdk/EntryTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,19 @@ public void onCompletion(ResponseType responseType, Error error) {
});
}

@Test
public void test_14_entry_include_embedded_items() throws Exception {
final Entry entry = stack.contentType("categories").entry(entryUID);
entry.includeEmbeddedItems().fetch(new EntryResultCallBack() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
if (error == null) {
boolean _embedded_items = entry.toJSON().has("_embedded_items");
TestCase.assertTrue(_embedded_items);
}
TestCase.assertTrue(entry.otherPostJSON.has("include_embedded_items[]"));
}
});
}

}
19 changes: 19 additions & 0 deletions src/test/java/com/contentstack/sdk/QueryTestCase.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.contentstack.sdk;

import io.github.cdimascio.dotenv.Dotenv;
import junit.framework.TestCase;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.After;
Expand Down Expand Up @@ -770,4 +771,22 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
});
}

@Test
public void test_43_entry_include_embedded_items() {
final Query query = stack.contentType("categories").query();
query.includeEmbeddedItems().find(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) {
if (error == null) {
List<Entry> arryResult = queryresult.getResultObjects();
for (Entry entry : arryResult) {
boolean _embedded_items = entry.toJSON().has("_embedded_items");
//TestCase.assertTrue(_embedded_items);
}
}
TestCase.assertTrue(query.urlQueries.has("include_embedded_items[]"));
}
});
}

}