Skip to content

Commit

Permalink
Merge pull request #94 from contentstack/master
Browse files Browse the repository at this point in the history
Back Merge
  • Loading branch information
cs-raj authored Oct 17, 2024
2 parents 89193b7 + d2a692d commit 362a8aa
Show file tree
Hide file tree
Showing 51 changed files with 226 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: mvn jacoco:prepare-agent jacoco:report

- name: Upload Code Coverage Report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: target/site/jacoco
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v1.5.0

### Sept 16, 2024

- includeReference method implemented

## v1.4.3

### July 08, 2024
Expand Down
23 changes: 17 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>cms</artifactId>
<packaging>jar</packaging>
<name>contentstack-management-java</name>
<version>1.4.3</version>
<version>1.5.0</version>
<description>Contentstack Java Management SDK for Content Management API, Contentstack is a headless CMS with an
API-first approach
</description>
Expand Down Expand Up @@ -54,7 +54,7 @@
<organizationUrl>https://www.contentstack.com/</organizationUrl>
</developer>
<developer>
<name>ishaileshmishra</name>
<name>***REMOVED***</name>
<email>[email protected]</email>
<organization>contentstack</organization>
<organizationUrl>https://www.contentstack.com/</organizationUrl>
Expand Down Expand Up @@ -91,11 +91,11 @@
<rxjava-source.version>3.1.8</rxjava-source.version>
<retrofit-source.version>2.10.0</retrofit-source.version>
<converter-gson-version>2.10.0</converter-gson-version>
<logging.version>5.0.0-alpha.12</logging.version>
<okhttp.version>4.12.0</okhttp.version>
<jococo-plugin.version>0.8.7</jococo-plugin.version>
<lombok-source.version>1.18.32</lombok-source.version>
<junit-jupiter.version>5.10.1</junit-jupiter.version>
<junit-jupiter-engine.version>5.8.0-M1</junit-jupiter-engine.version>
<junit-jupiter-engine.version>5.10.1</junit-jupiter-engine.version>
<gson.version>2.10.1</gson.version>
<maven-site-plugin.version>3.3</maven-site-plugin.version>
<maven-gpg-plugin.version>1.5</maven-gpg-plugin.version>
Expand Down Expand Up @@ -132,9 +132,20 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${logging.version}</version>
<version>${okhttp.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>${okhttp.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand Down Expand Up @@ -253,7 +264,7 @@
</plugin>

<!-- -overview
"/Users/shaileshmishra/Documents/Workspace/contentstack/java/contentstack-management-java/src/main/overview.html"
"***REMOVED***tentstack/java/contentstack-management-java/src/main/overview.html"
-bottom "<b>Copyright © 2012-2022 Contentstack </b><sup>TM</sup>"-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/contentstack/cms/Contentstack.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class Contentstack {
* <br>
*
* @return User
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#users">User
* </a>
Expand Down Expand Up @@ -129,7 +129,7 @@ public User user() {
* @param password the password of the user
* @return LoginDetails
* @throws IOException the IOException
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#users">User
* </a>
Expand Down Expand Up @@ -182,7 +182,7 @@ public Response<LoginDetails> login(String emailId, String password) throws IOEx
* @return LoginDetails
* @throws IOException the io exception
* @throws IOException the IOException
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a
* href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#log-in-to-your-account">Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* API implementation, you'll want to pass the auth token as the value for the
* Authorization header.
*
* @author ishaileshmishra
* @author ***REMOVED***
* @since v0.1.0
*/
public class AuthInterceptor implements Interceptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* an illegal or unsuitable argument
* passed to a method.
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @since 2022-10-20
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/contentstack/cms/core/CMALogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* The Contentstack Logger
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @since 2022-10-20
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* CMARuntimeException that extends Exception class
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @since 2022-10-20
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* The Contentstack ResponseResult class that accepts different types of Models
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @since 2022-10-20
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/contentstack/cms/core/RetryCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* The Contentstack RetryCallback
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @since 2022-10-20
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/contentstack/cms/core/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* The utility class that contains utility common functions
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @since 2022-10-20
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* users. Organization allows easy management of projects as well as users
* within the Organization.
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @since 2022-10-20
*/
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/contentstack/cms/stack/Alias.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* ID in your frontend code to pull content
* from the target branch associated with an alias.
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @see <a href= "https://www.contentstack.com/docs/developers/apis/content-management-api/#aliases">About Aliases </a>
* @since 2022 -10-20
Expand Down Expand Up @@ -138,7 +138,7 @@ protected void clearParams() {
* aliases available in a particular stack in your account.
*
* @return Call
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-all-aliases">Get
* all
Expand All @@ -153,7 +153,7 @@ public Call<ResponseBody> find() {
* The Get a single alias request returns information of a specific alias.
*
* @return Call
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-a-single-branch">
* Get a single branch</a>
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/contentstack/cms/stack/Asset.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* so on) uploaded in your Contentstack
* repository for future use.
*
* @author ishaileshmishra
* @author ***REMOVED***
* @since 2022-10-20
*/
public class Asset implements BaseImplementation<Asset> {
Expand Down Expand Up @@ -187,7 +187,7 @@ public Folder folder(@NotNull String folderUid) {
* Example:file_size
*
* @return Call
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-all-assets">Get
* all
Expand All @@ -210,7 +210,7 @@ public Call<ResponseBody> find() {
* published in each of the environment.
*
* @return Call
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-a-single-asset">Get
* a single asset</a>
Expand All @@ -228,7 +228,7 @@ public Call<ResponseBody> fetch() {
*
* @param folderUid The folderUid of specific folder
* @return Call
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-assets-of-a-specific-folder">Get
* Assets of a Specific Folder</a>
Expand All @@ -249,7 +249,7 @@ public Call<ResponseBody> byFolderUid(@NotNull String folderUid) {
* @param folderUid folder uid
* @param isIncludeFolders provide true/false
* @return Call
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-assets-and-subfolders-of-a-parent-folder">Get
* Assets and Subfolders of a Parent Folder</a>
Expand Down Expand Up @@ -296,7 +296,7 @@ public Call<ResponseBody> subfolder(
* in the response.</li>
* </ul>
* @return Call
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#upload-asset">
* Upload
Expand Down Expand Up @@ -410,7 +410,7 @@ private MultipartBody.Part uploadFile(@NotNull String filePath) {
*
* @param body the JSONObject request body
* @return Call
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#generate-permanent-asset-url">
* Generate Permanent Asset URL </a>
Expand Down Expand Up @@ -439,7 +439,7 @@ public Call<ResponseBody> generatePermanentUrl(JSONObject body) {
*
* @param slugUrl The unique identifier of the asset.
* @return Call
* @author ishaileshmishra
* @author ***REMOVED***
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#generate-permanent-asset-url">
* Generate Permanent Asset Url</a>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/contentstack/cms/stack/AuditLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#audit-log">Audit
* Log</a>
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @since 2022-10-22
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/contentstack/cms/stack/Branch.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* parallel in a more collaborative, organized,
* and structured manner without impacting each other.
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v1.0.0
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#branches">About
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* bulk operations on search results
* <br>
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v1.0.0
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#bulk-publish-operation">
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/contentstack/cms/stack/ContentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* key in the response. This key specifies the unique ID of the branch where the
* concerned Contentstack module resides.
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#content-types">Content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* requests over your stack content, you can use Management Tokens
* <br>
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @since 2022-10-22
*/
Expand Down
31 changes: 30 additions & 1 deletion src/main/java/com/contentstack/cms/stack/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import retrofit2.Call;
import retrofit2.Retrofit;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

Expand All @@ -22,7 +25,7 @@
* key in the response. This key specifies the unique ID of the branch where the
* concerned Contentstack module resides.
*
* @author ishaileshmishra
* @author ***REMOVED***
* @version v0.1.0
* @since 2022-10-22
*/
Expand All @@ -35,6 +38,7 @@ public class Entry implements BaseImplementation<Entry> {
protected final EntryService service;
protected final String contentTypeUid;
protected final String entryUid;
private int includeCounter = 1;

protected Entry(Retrofit instance, Map<String, Object> headers, String contentTypeUid) {
this.contentTypeUid = contentTypeUid;
Expand Down Expand Up @@ -82,6 +86,7 @@ public Entry addHeader(@NotNull String key, @NotNull String value) {
* @param value query param value for the request
* @return instance of {@link Entry}
*/
@Override
public Entry addParam(@NotNull String key, @NotNull Object value) {
this.params.put(key, value);
return this;
Expand Down Expand Up @@ -121,6 +126,30 @@ protected Entry clearParams() {
return this;
}

protected Entry addToParams(@NotNull String key, @NotNull Object value){
if (key.equals("include[]")) {
if (value instanceof String[]) {
for (String item : (String[]) value) {
this.params.put(key + includeCounter++, item);
}
} else if (value instanceof String) {
this.params.put(key, value);
}
} else {
this.params.put(key, value);
}
return this;
}

public Call<ResponseBody> includeReference(@NotNull Object referenceField){
if (referenceField instanceof String || referenceField instanceof String[]) {
addToParams("include[]", referenceField);
} else {
throw new IllegalArgumentException("Reference fields must be a String or an array of Strings");
}
validateCT();
return this.service.fetch(this.headers, this.contentTypeUid, this.params);
}
/**
* <b>Fetches the list of all the entries of a particular content type.</b>
* It also returns the content of each entry in JSON format. You can also
Expand Down
Loading

0 comments on commit 362a8aa

Please sign in to comment.