diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index a03b7585..3ff0db47 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -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 diff --git a/changelog.md b/changelog.md index 940c5d48..bd5af9a0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## v1.5.0 + +### Sept 16, 2024 + +- includeReference method implemented + ## v1.4.3 ### July 08, 2024 diff --git a/pom.xml b/pom.xml index cb50d2f0..fd47e216 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ cms jar contentstack-management-java - 1.4.3 + 1.5.0 Contentstack Java Management SDK for Content Management API, Contentstack is a headless CMS with an API-first approach @@ -54,7 +54,7 @@ https://www.contentstack.com/ - ishaileshmishra + ***REMOVED*** mshaileshr@gmail.com contentstack https://www.contentstack.com/ @@ -91,11 +91,11 @@ 3.1.8 2.10.0 2.10.0 - 5.0.0-alpha.12 + 4.12.0 0.8.7 1.18.32 5.10.1 - 5.8.0-M1 + 5.10.1 2.10.1 3.3 1.5 @@ -132,9 +132,20 @@ com.squareup.okhttp3 logging-interceptor - ${logging.version} + ${okhttp.version} compile + + com.squareup.okhttp3 + okhttp + ${okhttp.version} + + + com.squareup.okhttp3 + mockwebserver + ${okhttp.version} + test + org.jetbrains annotations @@ -253,7 +264,7 @@ org.apache.maven.plugins diff --git a/src/main/java/com/contentstack/cms/Contentstack.java b/src/main/java/com/contentstack/cms/Contentstack.java index 60db4e6b..d5cd049a 100644 --- a/src/main/java/com/contentstack/cms/Contentstack.java +++ b/src/main/java/com/contentstack/cms/Contentstack.java @@ -79,7 +79,7 @@ public class Contentstack { *
* * @return User - * @author ishaileshmishra + * @author ***REMOVED*** * @see User * @@ -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 User * @@ -182,7 +182,7 @@ public Response login(String emailId, String password) throws IOEx * @return LoginDetails * @throws IOException the io exception * @throws IOException the IOException - * @author ishaileshmishra + * @author ***REMOVED*** * @see Login diff --git a/src/main/java/com/contentstack/cms/core/AuthInterceptor.java b/src/main/java/com/contentstack/cms/core/AuthInterceptor.java index d5b807dc..adf49001 100644 --- a/src/main/java/com/contentstack/cms/core/AuthInterceptor.java +++ b/src/main/java/com/contentstack/cms/core/AuthInterceptor.java @@ -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 { diff --git a/src/main/java/com/contentstack/cms/core/BadArgumentException.java b/src/main/java/com/contentstack/cms/core/BadArgumentException.java index 07dbe683..db02e159 100644 --- a/src/main/java/com/contentstack/cms/core/BadArgumentException.java +++ b/src/main/java/com/contentstack/cms/core/BadArgumentException.java @@ -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 */ diff --git a/src/main/java/com/contentstack/cms/core/CMALogger.java b/src/main/java/com/contentstack/cms/core/CMALogger.java index f52291e7..6c49a0f5 100644 --- a/src/main/java/com/contentstack/cms/core/CMALogger.java +++ b/src/main/java/com/contentstack/cms/core/CMALogger.java @@ -7,7 +7,7 @@ /** * The Contentstack Logger * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-20 */ diff --git a/src/main/java/com/contentstack/cms/core/CMARuntimeException.java b/src/main/java/com/contentstack/cms/core/CMARuntimeException.java index 64cf8bc4..5ccb2167 100644 --- a/src/main/java/com/contentstack/cms/core/CMARuntimeException.java +++ b/src/main/java/com/contentstack/cms/core/CMARuntimeException.java @@ -3,7 +3,7 @@ /** * CMARuntimeException that extends Exception class * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-20 */ diff --git a/src/main/java/com/contentstack/cms/core/ResponseResult.java b/src/main/java/com/contentstack/cms/core/ResponseResult.java index bea369b0..d69be02b 100644 --- a/src/main/java/com/contentstack/cms/core/ResponseResult.java +++ b/src/main/java/com/contentstack/cms/core/ResponseResult.java @@ -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 */ diff --git a/src/main/java/com/contentstack/cms/core/RetryCallback.java b/src/main/java/com/contentstack/cms/core/RetryCallback.java index 2b7bf26c..f75a55ea 100644 --- a/src/main/java/com/contentstack/cms/core/RetryCallback.java +++ b/src/main/java/com/contentstack/cms/core/RetryCallback.java @@ -9,7 +9,7 @@ /** * The Contentstack RetryCallback * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-20 */ diff --git a/src/main/java/com/contentstack/cms/core/Util.java b/src/main/java/com/contentstack/cms/core/Util.java index 54092373..7049f198 100644 --- a/src/main/java/com/contentstack/cms/core/Util.java +++ b/src/main/java/com/contentstack/cms/core/Util.java @@ -9,7 +9,7 @@ /** * The utility class that contains utility common functions * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-20 */ diff --git a/src/main/java/com/contentstack/cms/organization/Organization.java b/src/main/java/com/contentstack/cms/organization/Organization.java index 52fb13b6..dfdae44d 100644 --- a/src/main/java/com/contentstack/cms/organization/Organization.java +++ b/src/main/java/com/contentstack/cms/organization/Organization.java @@ -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 */ diff --git a/src/main/java/com/contentstack/cms/stack/Alias.java b/src/main/java/com/contentstack/cms/stack/Alias.java index b939b4ac..c074fc1d 100644 --- a/src/main/java/com/contentstack/cms/stack/Alias.java +++ b/src/main/java/com/contentstack/cms/stack/Alias.java @@ -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 About Aliases * @since 2022 -10-20 @@ -138,7 +138,7 @@ protected void clearParams() { * aliases available in a particular stack in your account. * * @return Call - * @author ishaileshmishra + * @author ***REMOVED*** * @see Get * all @@ -153,7 +153,7 @@ public Call find() { * The Get a single alias request returns information of a specific alias. * * @return Call - * @author ishaileshmishra + * @author ***REMOVED*** * @see * Get a single branch diff --git a/src/main/java/com/contentstack/cms/stack/Asset.java b/src/main/java/com/contentstack/cms/stack/Asset.java index db08cb6a..6cd802ae 100644 --- a/src/main/java/com/contentstack/cms/stack/Asset.java +++ b/src/main/java/com/contentstack/cms/stack/Asset.java @@ -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 { @@ -187,7 +187,7 @@ public Folder folder(@NotNull String folderUid) { * Example:file_size * * @return Call - * @author ishaileshmishra + * @author ***REMOVED*** * @see Get * all @@ -210,7 +210,7 @@ public Call find() { * published in each of the environment. * * @return Call - * @author ishaileshmishra + * @author ***REMOVED*** * @see Get * a single asset @@ -228,7 +228,7 @@ public Call fetch() { * * @param folderUid The folderUid of specific folder * @return Call - * @author ishaileshmishra + * @author ***REMOVED*** * @see Get * Assets of a Specific Folder @@ -249,7 +249,7 @@ public Call byFolderUid(@NotNull String folderUid) { * @param folderUid folder uid * @param isIncludeFolders provide true/false * @return Call - * @author ishaileshmishra + * @author ***REMOVED*** * @see Get * Assets and Subfolders of a Parent Folder @@ -296,7 +296,7 @@ public Call subfolder( * in the response. * * @return Call - * @author ishaileshmishra + * @author ***REMOVED*** * @see * Upload @@ -410,7 +410,7 @@ private MultipartBody.Part uploadFile(@NotNull String filePath) { * * @param body the JSONObject request body * @return Call - * @author ishaileshmishra + * @author ***REMOVED*** * @see * Generate Permanent Asset URL @@ -439,7 +439,7 @@ public Call generatePermanentUrl(JSONObject body) { * * @param slugUrl The unique identifier of the asset. * @return Call - * @author ishaileshmishra + * @author ***REMOVED*** * @see * Generate Permanent Asset Url diff --git a/src/main/java/com/contentstack/cms/stack/AuditLog.java b/src/main/java/com/contentstack/cms/stack/AuditLog.java index 83df9bcd..d7ce42d3 100644 --- a/src/main/java/com/contentstack/cms/stack/AuditLog.java +++ b/src/main/java/com/contentstack/cms/stack/AuditLog.java @@ -27,7 +27,7 @@ * "https://www.contentstack.com/docs/developers/apis/content-management-api/#audit-log">Audit * Log * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-22 */ diff --git a/src/main/java/com/contentstack/cms/stack/Branch.java b/src/main/java/com/contentstack/cms/stack/Branch.java index e10d6bee..f4572d57 100644 --- a/src/main/java/com/contentstack/cms/stack/Branch.java +++ b/src/main/java/com/contentstack/cms/stack/Branch.java @@ -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 About diff --git a/src/main/java/com/contentstack/cms/stack/BulkOperation.java b/src/main/java/com/contentstack/cms/stack/BulkOperation.java index 8b40ab9f..52bcb1d8 100644 --- a/src/main/java/com/contentstack/cms/stack/BulkOperation.java +++ b/src/main/java/com/contentstack/cms/stack/BulkOperation.java @@ -21,7 +21,7 @@ * bulk operations on search results *
* - * @author ishaileshmishra + * @author ***REMOVED*** * @version v1.0.0 * @see
diff --git a/src/main/java/com/contentstack/cms/stack/ContentType.java b/src/main/java/com/contentstack/cms/stack/ContentType.java index 7b43924c..c26de5a2 100644 --- a/src/main/java/com/contentstack/cms/stack/ContentType.java +++ b/src/main/java/com/contentstack/cms/stack/ContentType.java @@ -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 Content diff --git a/src/main/java/com/contentstack/cms/stack/DeliveryToken.java b/src/main/java/com/contentstack/cms/stack/DeliveryToken.java index 8c113fdf..f0aa8cc5 100644 --- a/src/main/java/com/contentstack/cms/stack/DeliveryToken.java +++ b/src/main/java/com/contentstack/cms/stack/DeliveryToken.java @@ -20,7 +20,7 @@ * requests over your stack content, you can use Management Tokens *
* - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-22 */ diff --git a/src/main/java/com/contentstack/cms/stack/Entry.java b/src/main/java/com/contentstack/cms/stack/Entry.java index 3cd525d9..d7893869 100644 --- a/src/main/java/com/contentstack/cms/stack/Entry.java +++ b/src/main/java/com/contentstack/cms/stack/Entry.java @@ -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; @@ -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 */ @@ -35,6 +38,7 @@ public class Entry implements BaseImplementation { protected final EntryService service; protected final String contentTypeUid; protected final String entryUid; + private int includeCounter = 1; protected Entry(Retrofit instance, Map headers, String contentTypeUid) { this.contentTypeUid = contentTypeUid; @@ -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; @@ -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 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); + } /** * Fetches the list of all the entries of a particular content type. * It also returns the content of each entry in JSON format. You can also diff --git a/src/main/java/com/contentstack/cms/stack/EntryService.java b/src/main/java/com/contentstack/cms/stack/EntryService.java index 3fe6d220..fa6ff789 100644 --- a/src/main/java/com/contentstack/cms/stack/EntryService.java +++ b/src/main/java/com/contentstack/cms/stack/EntryService.java @@ -5,6 +5,7 @@ import retrofit2.Call; import retrofit2.http.*; +import java.util.List; import java.util.Map; public interface EntryService { @@ -13,7 +14,7 @@ public interface EntryService { Call fetch( @HeaderMap Map headers, @Path("content_type_uid") String contentTypeUid, - @QueryMap(encoded = true) Map queryParameter); + @QueryMap(encoded = true) Map queryParameter); @Headers("Content-Type: application/json") @GET("content_types/{content_type_uid}/entries/{entry_uid}") diff --git a/src/main/java/com/contentstack/cms/stack/Environment.java b/src/main/java/com/contentstack/cms/stack/Environment.java index e2e76c0c..8ef0c9d2 100644 --- a/src/main/java/com/contentstack/cms/stack/Environment.java +++ b/src/main/java/com/contentstack/cms/stack/Environment.java @@ -16,7 +16,7 @@ * content delivery destination where the * entries need to be published. * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-22 */ diff --git a/src/main/java/com/contentstack/cms/stack/Extensions.java b/src/main/java/com/contentstack/cms/stack/Extensions.java index 063399ad..437c8cab 100644 --- a/src/main/java/com/contentstack/cms/stack/Extensions.java +++ b/src/main/java/com/contentstack/cms/stack/Extensions.java @@ -25,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 */ diff --git a/src/main/java/com/contentstack/cms/stack/GlobalField.java b/src/main/java/com/contentstack/cms/stack/GlobalField.java index c35c5688..47ad9599 100644 --- a/src/main/java/com/contentstack/cms/stack/GlobalField.java +++ b/src/main/java/com/contentstack/cms/stack/GlobalField.java @@ -24,7 +24,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 */ diff --git a/src/main/java/com/contentstack/cms/stack/Label.java b/src/main/java/com/contentstack/cms/stack/Label.java index bc5be506..d6b3943c 100644 --- a/src/main/java/com/contentstack/cms/stack/Label.java +++ b/src/main/java/com/contentstack/cms/stack/Label.java @@ -22,7 +22,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 */ diff --git a/src/main/java/com/contentstack/cms/stack/Locale.java b/src/main/java/com/contentstack/cms/stack/Locale.java index 8a1a5bf1..e8231b09 100644 --- a/src/main/java/com/contentstack/cms/stack/Locale.java +++ b/src/main/java/com/contentstack/cms/stack/Locale.java @@ -17,7 +17,7 @@ * to a wide variety of audience by serving * content in their local language(s). * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @see
diff --git a/src/main/java/com/contentstack/cms/stack/ManagementToken.java b/src/main/java/com/contentstack/cms/stack/ManagementToken.java index edef62bc..dda8a3eb 100644 --- a/src/main/java/com/contentstack/cms/stack/ManagementToken.java +++ b/src/main/java/com/contentstack/cms/stack/ManagementToken.java @@ -14,7 +14,7 @@ * content, you can use Management Tokens *
* - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-22 */ diff --git a/src/main/java/com/contentstack/cms/stack/Merge.java b/src/main/java/com/contentstack/cms/stack/Merge.java index 1099e52a..7632340c 100644 --- a/src/main/java/com/contentstack/cms/stack/Merge.java +++ b/src/main/java/com/contentstack/cms/stack/Merge.java @@ -38,7 +38,7 @@ * * * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v1.0.0 * @see
Merge diff --git a/src/main/java/com/contentstack/cms/stack/PublishQueue.java b/src/main/java/com/contentstack/cms/stack/PublishQueue.java index 11b8231e..0da7c651 100644 --- a/src/main/java/com/contentstack/cms/stack/PublishQueue.java +++ b/src/main/java/com/contentstack/cms/stack/PublishQueue.java @@ -28,7 +28,7 @@ * concerned Contentstack module resides. *
* - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @see
diff --git a/src/main/java/com/contentstack/cms/stack/Release.java b/src/main/java/com/contentstack/cms/stack/Release.java index 39b0a8b4..bba9bbdb 100644 --- a/src/main/java/com/contentstack/cms/stack/Release.java +++ b/src/main/java/com/contentstack/cms/stack/Release.java @@ -27,7 +27,7 @@ * Read more about Releases * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-22 */ diff --git a/src/main/java/com/contentstack/cms/stack/ReleaseItem.java b/src/main/java/com/contentstack/cms/stack/ReleaseItem.java index bf55891a..49b93cd5 100644 --- a/src/main/java/com/contentstack/cms/stack/ReleaseItem.java +++ b/src/main/java/com/contentstack/cms/stack/ReleaseItem.java @@ -19,7 +19,7 @@ * "https://www.contentstack.com/docs/developers/apis/content-management-api/#release-items">Release * Items * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-22 */ diff --git a/src/main/java/com/contentstack/cms/stack/Roles.java b/src/main/java/com/contentstack/cms/stack/Roles.java index bf0955e3..a3a51404 100644 --- a/src/main/java/com/contentstack/cms/stack/Roles.java +++ b/src/main/java/com/contentstack/cms/stack/Roles.java @@ -14,7 +14,7 @@ * A role is a collection of permissions that will be applicable to all the * users who are assigned this role. * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @see Roles diff --git a/src/main/java/com/contentstack/cms/stack/Stack.java b/src/main/java/com/contentstack/cms/stack/Stack.java index f99a43ee..35af7ccd 100644 --- a/src/main/java/com/contentstack/cms/stack/Stack.java +++ b/src/main/java/com/contentstack/cms/stack/Stack.java @@ -15,7 +15,7 @@ * property). Within a stack, you can create * content structures, content entries, users, etc. related to the project. * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022 -10-22 */ diff --git a/src/main/java/com/contentstack/cms/stack/Tokens.java b/src/main/java/com/contentstack/cms/stack/Tokens.java index 35d274d3..9c74bbf4 100644 --- a/src/main/java/com/contentstack/cms/stack/Tokens.java +++ b/src/main/java/com/contentstack/cms/stack/Tokens.java @@ -8,7 +8,7 @@ /** * Contentstack provides different types of tokens to authorize API requests * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-22 */ diff --git a/src/main/java/com/contentstack/cms/stack/Webhook.java b/src/main/java/com/contentstack/cms/stack/Webhook.java index a009fc49..d360ffbe 100644 --- a/src/main/java/com/contentstack/cms/stack/Webhook.java +++ b/src/main/java/com/contentstack/cms/stack/Webhook.java @@ -24,7 +24,7 @@ * Read more * about Webhooks. * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @see diff --git a/src/main/java/com/contentstack/cms/stack/Workflow.java b/src/main/java/com/contentstack/cms/stack/Workflow.java index 8a2d66c9..c43fde9e 100644 --- a/src/main/java/com/contentstack/cms/stack/Workflow.java +++ b/src/main/java/com/contentstack/cms/stack/Workflow.java @@ -21,7 +21,7 @@ * Note: You cannot create workflows in a stack that supports branches * when using the classic Contentstack interface. * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v01.0 * @since 2022-10-22 */ diff --git a/src/main/java/com/contentstack/cms/user/User.java b/src/main/java/com/contentstack/cms/user/User.java index fd9120d8..53b05b8f 100644 --- a/src/main/java/com/contentstack/cms/user/User.java +++ b/src/main/java/com/contentstack/cms/user/User.java @@ -19,7 +19,7 @@ * can have many users with varying * permissions and roles. * - * @author ishaileshmishra + * @author ***REMOVED*** * @version v0.1.0 * @since 2022-10-22 */ @@ -45,7 +45,7 @@ public class User implements BaseImplementation { * contentstack.user().execute();
* *
- * @author ishaileshmishra + * @author ***REMOVED*** */ public User(Retrofit client) { this.params = new HashMap<>(); diff --git a/src/main/overview.html b/src/main/overview.html index 51879411..4c49cdb9 100644 --- a/src/main/overview.html +++ b/src/main/overview.html @@ -91,7 +91,7 @@
  • Content Management API Docs
  • The MIT License (MIT)

    -

    Copyright © 2012-2023 Contentstack. All Rights Reserved

    +

    Copyright © 2012-2024 Contentstack. All Rights Reserved

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    diff --git a/src/test/java/com/contentstack/cms/ContentstackAPITest.java b/src/test/java/com/contentstack/cms/ContentstackAPITest.java index d2c0032a..6f1ca163 100644 --- a/src/test/java/com/contentstack/cms/ContentstackAPITest.java +++ b/src/test/java/com/contentstack/cms/ContentstackAPITest.java @@ -11,7 +11,7 @@ import java.io.IOException; /* - @author ishaileshmishra@gmail.com + @author ***REMOVED***@gmail.com @since CMS v0.0.1 */ public class ContentstackAPITest { diff --git a/src/test/java/com/contentstack/cms/ContentstackUnitTest.java b/src/test/java/com/contentstack/cms/ContentstackUnitTest.java index eaca866e..6386cf22 100644 --- a/src/test/java/com/contentstack/cms/ContentstackUnitTest.java +++ b/src/test/java/com/contentstack/cms/ContentstackUnitTest.java @@ -1,9 +1,15 @@ package com.contentstack.cms; +import com.contentstack.cms.core.AuthInterceptor; import com.contentstack.cms.organization.Organization; import com.contentstack.cms.stack.Stack; import okhttp3.Headers; +import okhttp3.OkHttpClient; +import okhttp3.Request; import okhttp3.ResponseBody; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import retrofit2.Response; @@ -262,5 +268,66 @@ public void testEmptyOrganizationUid() { Assertions.assertThrows(IllegalStateException.class, () -> client.organization(emptyOrganizationUid)); } + @Test + public void testEarlyAccessHeader() throws IOException, InterruptedException { + MockWebServer mockWebServer = new MockWebServer(); + mockWebServer.enqueue(new MockResponse().setBody("{}")); + + AuthInterceptor authInterceptor = new AuthInterceptor(); + authInterceptor.setEarlyAccess(new String[]{"Taxonomy"}); + + OkHttpClient client = new OkHttpClient.Builder() + .addInterceptor(authInterceptor) + .build(); + + Request request = new Request.Builder() + .url(mockWebServer.url("/")) + .build(); + + client.newCall(request).execute(); + RecordedRequest recordedRequest = mockWebServer.takeRequest(); + String earlyAccessHeader = recordedRequest.getHeader("x-header-ea"); + + Assertions.assertNotNull(earlyAccessHeader); + Assertions.assertEquals("Taxonomy", earlyAccessHeader); + + mockWebServer.shutdown(); + } + @Test + public void testEarlyAccessMultipleHeader() throws IOException, InterruptedException { + MockWebServer mockWebServer = new MockWebServer(); + mockWebServer.enqueue(new MockResponse().setBody("{}")); + + AuthInterceptor authInterceptor = new AuthInterceptor(); + authInterceptor.setEarlyAccess(new String[]{"Taxonomy","Teams"}); + + OkHttpClient client = new OkHttpClient.Builder() + .addInterceptor(authInterceptor) + .build(); + + Request request = new Request.Builder() + .url(mockWebServer.url("/")) + .build(); + + client.newCall(request).execute(); + RecordedRequest recordedRequest = mockWebServer.takeRequest(); + String earlyAccessHeader = recordedRequest.getHeader("x-header-ea"); + + Assertions.assertNotNull(earlyAccessHeader); + Assertions.assertEquals("Taxonomy, Teams", earlyAccessHeader); + + mockWebServer.shutdown(); + } + + @Test + public void testEarlyAccessHeaderEmpty() { + String[] emptyEarlyAccessFeatures = {}; + Contentstack client = new Contentstack.Builder() + .earlyAccess(emptyEarlyAccessFeatures) + .build(); + + Assertions.assertNotNull(client.earlyAccess); + Assertions.assertEquals(0, client.earlyAccess.length); + } } diff --git a/src/test/java/com/contentstack/cms/TestClient.java b/src/test/java/com/contentstack/cms/TestClient.java index c30f7e99..37444610 100644 --- a/src/test/java/com/contentstack/cms/TestClient.java +++ b/src/test/java/com/contentstack/cms/TestClient.java @@ -48,7 +48,7 @@ public static Contentstack getCustomClient() { instance = new Contentstack.Builder() .setAuthtoken(AUTHTOKEN) .setConnectionPool(5, 400, TimeUnit.MILLISECONDS) - .setHost("kpm.ishaileshmishra.io/path/another").build(); + .setHost("kpm.***REMOVED***.io/path/another").build(); } } } diff --git a/src/test/java/com/contentstack/cms/models/LoginDetailTest.java b/src/test/java/com/contentstack/cms/models/LoginDetailTest.java index 115ab438..b73ec23f 100644 --- a/src/test/java/com/contentstack/cms/models/LoginDetailTest.java +++ b/src/test/java/com/contentstack/cms/models/LoginDetailTest.java @@ -86,24 +86,24 @@ void getterSetterUserModelFailedAttempts() { @Test void getterSetterUserModelFirstName() { UserModel userModel = new UserModel(); - userModel.setFirstName("ishaileshmishra"); - Assertions.assertEquals("ishaileshmishra", + userModel.setFirstName("***REMOVED***"); + Assertions.assertEquals("***REMOVED***", userModel.getFirstName()); } @Test void getterSetterUserModelLastName() { UserModel userModel = new UserModel(); - userModel.setLastName("ishaileshmishra"); - Assertions.assertEquals("ishaileshmishra", + userModel.setLastName("***REMOVED***"); + Assertions.assertEquals("***REMOVED***", userModel.getLastName()); } @Test void getterSetterUserModelUsername() { UserModel userModel = new UserModel(); - userModel.setUsername("ishaileshmishra"); - Assertions.assertEquals("ishaileshmishra", + userModel.setUsername("***REMOVED***"); + Assertions.assertEquals("***REMOVED***", userModel.getUsername()); } diff --git a/src/test/java/com/contentstack/cms/organization/OrgUnitTests.java b/src/test/java/com/contentstack/cms/organization/OrgUnitTests.java index df697565..33687684 100644 --- a/src/test/java/com/contentstack/cms/organization/OrgUnitTests.java +++ b/src/test/java/com/contentstack/cms/organization/OrgUnitTests.java @@ -457,7 +457,7 @@ void testGetAllInvitationsRequestParam() { @Test @Order(38) void testTransferOwnershipMethod() { - //String transferToEmail = "ishaileshmishra@gmail.com"; + //String transferToEmail = "***REMOVED***@gmail.com"; Request requestInfo = organization.transferOwnership(new JSONObject()).request(); Assertions.assertEquals("POST", requestInfo.method()); @@ -466,7 +466,7 @@ void testTransferOwnershipMethod() { @Test @Order(39) void testTransferOwnershipEncodedPath() { - // String transferToEmail = "ishaileshmishra@gmail.com"; + // String transferToEmail = "***REMOVED***@gmail.com"; Request requestInfo = organization.transferOwnership(new JSONObject()).request(); Assertions.assertEquals("/v3/organizations/" + organizationUid + "/transfer-ownership", requestInfo.url().encodedPath()); @@ -481,7 +481,7 @@ void testTransferOwnershipHeaders() { @Test @Order(41) void testTransferOwnershipRequestBody() { - //String transferToEmail = "ishaileshmishra@gmail.com"; + //String transferToEmail = "***REMOVED***@gmail.com"; Request requestInfo = organization.transferOwnership(new JSONObject()).request(); assertNull( requestInfo.url().encodedQuery()); diff --git a/src/test/java/com/contentstack/cms/stack/AssetAPITest.java b/src/test/java/com/contentstack/cms/stack/AssetAPITest.java index c64b1a8b..6c38a297 100644 --- a/src/test/java/com/contentstack/cms/stack/AssetAPITest.java +++ b/src/test/java/com/contentstack/cms/stack/AssetAPITest.java @@ -174,7 +174,7 @@ void testAssetReplace() throws IOException { asset.addHeader("authorization", MANAGEMENT_TOKEN); // Create Asset Instance to find all assets String filePath = "/Users/shaileshmishra/Downloads/calendar.png"; - Response resp = asset.replace(filePath, "Assets created by ishaileshmishra").execute(); + Response resp = asset.replace(filePath, "Assets created by ***REMOVED***").execute(); // The assertions Assertions.assertEquals(6, resp.raw().request().headers().size()); Assertions.assertTrue(resp.raw().request().headers().names().contains("api_key")); @@ -248,7 +248,7 @@ void testAssetDownloadPermanentUrl() throws IOException { @Test void testAssetUploadWithMultipleParams() throws IOException { - String description = "The calender has been placed to assets by ishaileshmishra"; + String description = "The calender has been placed to assets by ***REMOVED***"; String filePath = "/Users/shaileshmishra/Documents/workspace/GitHub/contentstack-management-java/src/test/resources/asset.png"; Contentstack client = new Contentstack.Builder().build(); Stack stack = client.stack("Your-api-key", "authorization"); diff --git a/src/test/java/com/contentstack/cms/stack/AssetUnitTest.java b/src/test/java/com/contentstack/cms/stack/AssetUnitTest.java index e642347b..8abfb6aa 100644 --- a/src/test/java/com/contentstack/cms/stack/AssetUnitTest.java +++ b/src/test/java/com/contentstack/cms/stack/AssetUnitTest.java @@ -168,7 +168,7 @@ void testAssetReplace() { asset.addParam("include_dimension", true); String filePath = "/Users/shaileshmishra/Downloads/calendar.png"; - Request resp = asset.replace(filePath, "The calender has been placed to assets by ishaileshmishra") + Request resp = asset.replace(filePath, "The calender has been placed to assets by ***REMOVED***") .request(); Assertions.assertTrue(resp.isHttps()); Assertions.assertEquals("PUT", resp.method()); diff --git a/src/test/java/com/contentstack/cms/stack/EntryFieldUnitTests.java b/src/test/java/com/contentstack/cms/stack/EntryFieldUnitTests.java index f9701a5a..1b2f1909 100644 --- a/src/test/java/com/contentstack/cms/stack/EntryFieldUnitTests.java +++ b/src/test/java/com/contentstack/cms/stack/EntryFieldUnitTests.java @@ -2,13 +2,20 @@ import com.contentstack.cms.Contentstack; import com.contentstack.cms.TestClient; +import com.google.gson.JsonArray; + import okhttp3.Request; + import okhttp3.ResponseBody; +import retrofit2.Response; + import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.junit.jupiter.api.*; +import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -93,6 +100,29 @@ void testSingleEntryQuery() { Request resp = entryInstance.fetch().request(); Assertions.assertEquals("include_publish_details=true&locale=en-us&include_workflow=false", resp.url().query()); } + @Test + void testIncludeReferenceSingleReference(){ + Request request = entryInstance.includeReference("reference").request(); + Assertions.assertEquals("include[]=reference", request.url().query()); + } + @Test + void testIncludeReferenceMultipleReferences() { + String[] array = {"reference","navigation_menu.page_reference"}; + Request req = entryInstance.includeReference(array).request(); + Assertions.assertEquals("include[]1=reference&include[]2=navigation_menu.page_reference", req.url().query()); + } + + @Test + void testIncludeReferenceMultipleReferencesWithParams() throws IOException { + entryInstance.clearParams(); + entryInstance.addParam("locale", "en-us"); + String[] array = {"reference","navigation_menu.page_reference"}; + entryInstance.addParam("include_workflow", false); + entryInstance.addParam("include_publish_details", true); + Request req = entryInstance.includeReference(array).request(); + Assertions.assertEquals("include[]1=reference&include_publish_details=true&include[]2=navigation_menu.page_reference&locale=en-us&include_workflow=false", req.url().query()); + + } @Test void testSingleEntryEncodedPath() { diff --git a/src/test/java/com/contentstack/cms/stack/EntryFieldsAPITest.java b/src/test/java/com/contentstack/cms/stack/EntryFieldsAPITest.java index 8e4753fa..ec99a09f 100644 --- a/src/test/java/com/contentstack/cms/stack/EntryFieldsAPITest.java +++ b/src/test/java/com/contentstack/cms/stack/EntryFieldsAPITest.java @@ -62,7 +62,7 @@ void testEntryFetch() { void testEntryCreate() { JSONObject body = new JSONObject(); body.put("title", "The Create an entry call creates a new entry for the selected content type for testing"); - body.put("url", "www.ishaileshmishra.in/stack/content_type/entry/fakeuid/code"); + body.put("url", "www.***REMOVED***.in/stack/content_type/entry/fakeuid/code"); JSONObject entryCreate = new JSONObject(); entryCreate.put("entry", body); Request request = entry.create(entryCreate).request(); @@ -82,7 +82,7 @@ void testEntryCreate() { void testUpdate() { JSONObject body = new JSONObject(); body.put("title", "The Create an entry call creates a new entry for the selected content type for testing"); - body.put("url", "www.ishaileshmishra.in/stack/content_type/entry/fakeuid/code"); + body.put("url", "www.***REMOVED***.in/stack/content_type/entry/fakeuid/code"); JSONObject entryUpdate = new JSONObject(); entryUpdate.put("entry", body); @@ -105,7 +105,7 @@ void testUpdate() { void testAtomicOperation() { JSONObject body = new JSONObject(); body.put("title", "The Create an entry call creates a new entry for the selected content type for testing"); - body.put("url", "www.ishaileshmishra.in/stack/content_type/entry/fakeuid/code"); + body.put("url", "www.***REMOVED***.in/stack/content_type/entry/fakeuid/code"); JSONObject entryBody = new JSONObject(); entryBody.put("entry", body); @@ -145,7 +145,7 @@ void testEntryDelete() { void testEntryVersionName() { JSONObject body = new JSONObject(); body.put("title", "The Create an entry call creates a new entry for the selected content type for testing"); - body.put("url", "www.ishaileshmishra.in/stack/content_type/entry/fakeuid/code"); + body.put("url", "www.***REMOVED***.in/stack/content_type/entry/fakeuid/code"); JSONObject entryBody = new JSONObject(); entryBody.put("entry", body); @@ -187,7 +187,7 @@ void testEntryDetailOfAllVersion() { void testEntryDeleteVersionName() { JSONObject body = new JSONObject(); body.put("title", "The Create an entry call creates a new entry for the selected content type for testing"); - body.put("url", "www.ishaileshmishra.in/stack/content_type/entry/fakeuid/code"); + body.put("url", "www.***REMOVED***.in/stack/content_type/entry/fakeuid/code"); JSONObject entryBody = new JSONObject(); entryBody.put("entry", body); @@ -229,7 +229,7 @@ void testEntryGetReference() { void testEntryLocalise() { JSONObject body = new JSONObject(); body.put("title", "The Create an entry call creates a new entry for the selected content type for testing"); - body.put("url", "www.ishaileshmishra.in/stack/content_type/entry/fakeuid/code"); + body.put("url", "www.***REMOVED***.in/stack/content_type/entry/fakeuid/code"); JSONObject entryBody = new JSONObject(); entryBody.put("entry", body); @@ -303,7 +303,7 @@ void testEntryImportExisting() { void testEntryPublish() { JSONObject body = new JSONObject(); body.put("title", "The Create an entry call creates a new entry for the selected content type for testing"); - body.put("url", "www.ishaileshmishra.in/stack/content_type/entry/fakeuid/code"); + body.put("url", "www.***REMOVED***.in/stack/content_type/entry/fakeuid/code"); JSONObject entryBody = new JSONObject(); entryBody.put("entry", body); @@ -326,7 +326,7 @@ void testEntryPublish() { void testEntryPublishWithReference() { JSONObject body = new JSONObject(); body.put("title", "The Create an entry call creates a new entry for the selected content type for testing"); - body.put("url", "www.ishaileshmishra.in/stack/content_type/entry/fakeuid/code"); + body.put("url", "www.***REMOVED***.in/stack/content_type/entry/fakeuid/code"); JSONObject entryBody = new JSONObject(); entryBody.put("entry", body); Request request = entry.publishWithReference(entryBody).request(); @@ -347,7 +347,7 @@ void testEntryPublishWithReference() { void testPublishWithReference() { JSONObject body = new JSONObject(); body.put("title", "The Create an entry call creates a new entry for the selected content type for testing"); - body.put("url", "www.ishaileshmishra.in/stack/content_type/entry/fakeuid/code"); + body.put("url", "www.***REMOVED***.in/stack/content_type/entry/fakeuid/code"); JSONObject entryBody = new JSONObject(); entryBody.put("entry", body); diff --git a/src/test/resources/entry.json b/src/test/resources/entry.json index d2f2d452..a7fd86c3 100644 --- a/src/test/resources/entry.json +++ b/src/test/resources/entry.json @@ -10,7 +10,7 @@ "tags": [ "abdn", "shailesh", - "ishaileshmishra", + "***REMOVED***", "nature", "loves" ], diff --git a/src/test/resources/mockstack/setting.json b/src/test/resources/mockstack/setting.json index 6b934c20..1ed9f2e2 100644 --- a/src/test/resources/mockstack/setting.json +++ b/src/test/resources/mockstack/setting.json @@ -5,7 +5,7 @@ "sys_rte_allowed_tags":"style, figure, script" }, "rte":{ - "ishaileshmishra":true + "***REMOVED***":true } } } \ No newline at end of file diff --git a/src/test/resources/mockstack/share_stack.json b/src/test/resources/mockstack/share_stack.json index ffdf7862..b22145ce 100644 --- a/src/test/resources/mockstack/share_stack.json +++ b/src/test/resources/mockstack/share_stack.json @@ -1,10 +1,10 @@ { "emails": [ - "ishaileshmishra@contentstack.com" + "***REMOVED***@contentstack.com" ], "roles": { "manager@example.com": [ - "ishaileshmishra8176367267626" + "***REMOVED***8176367267626" ] } } \ No newline at end of file diff --git a/src/test/resources/mockstack/unshare.json b/src/test/resources/mockstack/unshare.json index 5cd89d83..437c8054 100644 --- a/src/test/resources/mockstack/unshare.json +++ b/src/test/resources/mockstack/unshare.json @@ -1,3 +1,3 @@ { - "email": "ishaileshmishra@manager.com" + "email": "***REMOVED***@manager.com" } \ No newline at end of file