diff --git a/CHANGELOG.md b/CHANGELOG.md index fe4f1954..e09689d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,27 @@ # CHANGELOG -## Version 1.10.0 +## v1.10.1 -### Date: 16-May-2022 +### Date: 17-Jun-2022 + +- #57 CompileJava issue in Gradle build ecosystem (contentstack-utils) +- #58 content_type : Invalid warning for contentTypeUid + +--- + +## v1.10.0 + +### Date: 03-Jun-2022 - High increase in memory consumption & thread count when updated to the 1.9.0 version - Setting Proxy in config [#52](https://github.com/contentstack/contentstack-java/issues/52) - Adding query parameter for the Live Preview -- Enhancement in logger for the different class ( Suggested through a pull request ) [#51](https://github.com/contentstack/contentstack-java/pull/51) +- Enhancement in logger for the different class ( Suggested through a pull + request ) [#51](https://github.com/contentstack/contentstack-java/pull/51) --- -## Version 1.9.0 +## v1.9.0 ### Date: 16-Mar-2022 @@ -21,7 +31,7 @@ --- -## Version 1.8.1 +## v1.8.1 ### Date: 27-Jan-2022 @@ -31,7 +41,7 @@ --- -## Version 1.8.0 +## v1.8.0 ### Date: 01-Nov-2021 @@ -44,7 +54,7 @@ --- -## Version 1.7.0 +## v1.7.0 ### Date: 12-JUL-2021 @@ -54,7 +64,7 @@ --- -## Version 1.6.0 +## v1.6.0 ### Date: 05-APR-2021 @@ -63,7 +73,7 @@ --- -## Version 1.5.7 +## v1.5.7 ### Date: 20-Feb-2021 @@ -71,7 +81,7 @@ Document updated --- -## Version 1.5.6 +## v1.5.6 ### Date: 27-Jan-2021 @@ -82,7 +92,7 @@ New Features: --- -## Version 1.5.5 +## v1.5.5 ### Date: 22-Jan-2021 @@ -103,7 +113,7 @@ New Features: --- -## Version 1.5.4 +## v1.5.4 ### Date: 08-DEC-2020 @@ -116,7 +126,7 @@ New Features: --- -## Version 1.5.3 +## v1.5.3 ### Date: 28-July-2020 @@ -124,7 +134,7 @@ New Features: --- -## Version 1.5.2 +## v1.5.2 ### Date: 23-July-2020 @@ -134,7 +144,7 @@ New Features: --- -## Version 1.5.1 +## v1.5.1 ### Date: 13-Jan-2020 @@ -142,7 +152,7 @@ New Features: --- -## Version 1.5.0 +## v1.5.0 ### Date: 15-Nov-2019 @@ -153,7 +163,7 @@ New Features: --- -## Version 1.4.2 +## v1.4.2 ### Date: 03-Sept-2019 @@ -161,7 +171,7 @@ New Features: --- -## Version 1.4.1 +## v1.4.1 ### Date: 21-August-2019 @@ -170,7 +180,7 @@ New Features: --- -## Version 1.4.0 +## v1.4.0 ### Date: 26-July-2019 @@ -184,7 +194,7 @@ New Features: --- -## Version 1.3.3 +## v1.3.3 ### Date: 21-June-2019 @@ -192,7 +202,7 @@ New Features: --- -## Version 1.3.2 +## v1.3.2 ### Date: 13-May-2019 @@ -201,7 +211,7 @@ New Features: --- -## Version 1.3.1 +## v1.3.1 ### Date: May-02-2019 @@ -210,7 +220,7 @@ New Features: --- -## Version 1.3.0 +## v1.3.0 ### Date: Apr-12-2019 @@ -228,7 +238,7 @@ Below two support from the Config class has been removed permanently --- -## Version 1.2.1 +## v1.2.1 ### Date: 14-Mar-2019 @@ -240,7 +250,7 @@ Folder structure modified. --- -## Version 1.2.0 +## v1.2.0 ### Date: 15-Dec-2017 @@ -254,7 +264,7 @@ Folder structure modified. --- -## Version 1.1.0 +## v1.1.0 ### Date: 10-Nov-2017 diff --git a/pom.xml b/pom.xml index 9cf6d252..305e0905 100644 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,11 @@ - + 4.0.0 com.contentstack.sdk java - 1.10.0-SNAPSHOT + 1.10.1-SNAPSHOT jar contentstack-java Java SDK for Contentstack Content Delivery API @@ -12,16 +13,15 @@ - 1.10.0-SNAPSHOT - 1.10.0 + 1.10.1-SNAPSHOT 1.8 1.8 UTF-8 2.22.0 2.2.1 3.3.2 - 2.2.3 - 3.1.4 + 2.2.4 + 3.1.5 2.9.0 2.9.0 4.9.3 @@ -41,7 +41,7 @@ 0.8.7 2.5.3 1.6.7 - 1.1.1 + 1.1.2 diff --git a/src/main/java/com/contentstack/sdk/APIService.java b/src/main/java/com/contentstack/sdk/APIService.java index b8dd35cd..a537f0d8 100644 --- a/src/main/java/com/contentstack/sdk/APIService.java +++ b/src/main/java/com/contentstack/sdk/APIService.java @@ -8,6 +8,11 @@ import java.util.LinkedHashMap; +/** + * @author Shailesh Mishra + * @version 1.0.0 + * @since 12-12-2021 + */ public interface APIService { @GET Call getRequest(@Url String url, @HeaderMap LinkedHashMap headers); diff --git a/src/main/java/com/contentstack/sdk/Asset.java b/src/main/java/com/contentstack/sdk/Asset.java index ee5b51a3..5c022f2d 100644 --- a/src/main/java/com/contentstack/sdk/Asset.java +++ b/src/main/java/com/contentstack/sdk/Asset.java @@ -14,7 +14,16 @@ import static com.contentstack.sdk.Constants.parseDate; /** - * The type Asset. + * Assets + * refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository + * for future use. These files can be attached and used in multiple entries. + *

+ * You can now pass the branch header in the API request to fetch or manage modules located within specific branches of + * the stack. + * + * @author Shailesh Mishra + * @version 1.0.0 + * @since 01-11-2017 */ public class Asset { @@ -48,7 +57,8 @@ protected void setStackInstance(@NotNull Stack stack) { /** * Configure asset. * - * @param jsonObject the json object + * @param jsonObject + * the json object * @return the asset */ public Asset configure(JSONObject jsonObject) { @@ -67,18 +77,20 @@ public Asset configure(JSONObject jsonObject) { /** * Sets header. * - * @param headerKey the header key - * @param headerValue the header value + * @param headerKey + * the header key + * @param headerValue + * the header value * - *
- *
- * Example :
+ *
+ *
+ * Example :
* - *

-     *                    Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
-     *                    Asset asset = stack.asset(asset_uid);
-     *                    asset.setHeader();
-     *                    
+ *
+     *                                            Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
+     *                                            Asset asset = stack.asset(asset_uid);
+     *                                            asset.setHeader();
+     *                                            
*/ public void setHeader(@NotNull String headerKey, @NotNull String headerValue) { headers.put(headerKey, headerValue); @@ -87,19 +99,20 @@ public void setHeader(@NotNull String headerKey, @NotNull String headerValue) { /** * Remove header. * - * @param headerKey the header key + * @param headerKey + * the header key * * - *
- *
- * Example :
+ *
+ *
+ * Example :
* - *
-     *                  Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
-     *                  Asset asset = stack.asset(asset_uid);
-     *                  asset.removeHeader();
+     *         
+     *                                          Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
+     *                                          Asset asset = stack.asset(asset_uid);
+     *                                          asset.removeHeader();
      *
-     *                  
+ *
*/ public void removeHeader(@NotNull String headerKey) { headers.remove(headerKey); @@ -116,11 +129,11 @@ protected void setUid(@NotNull String assetUid) { * * @return the asset uid * - *
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -141,11 +154,11 @@ public String getAssetUid() {
      *
      * @return the file type
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -166,11 +179,11 @@ public String getFileType() {
      *
      * @return the file size
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -191,11 +204,11 @@ public String getFileSize() {
      *
      * @return the file name
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -213,14 +226,14 @@ public String getFileName() {
 
     /**
      * Gets url.
-     * 
+     *
      * @return the url
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -241,11 +254,11 @@ public String getUrl() {
      *
      * @return the json object
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -267,11 +280,11 @@ public JSONObject toJSON() {
      * @return the create at
      *
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -293,11 +306,11 @@ public Calendar getCreateAt() {
      * @return the created by
      *
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -319,11 +332,11 @@ public String getCreatedBy() {
      * @return the update at
      *
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -345,11 +358,11 @@ public Calendar getUpdateAt() {
      * @return the updated by
      *
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -370,11 +383,11 @@ public String getUpdatedBy() {
      *
      * @return the delete at
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -395,11 +408,11 @@ public Calendar getDeleteAt() {
      *
      * @return the deleted by
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -420,12 +433,12 @@ public String getDeletedBy() {
      *
      * @return the string [ ]
      *
-     * 
-     *         
- *
- * Example :
* - *
+     * 
+ *
+ * Example :
+ * + *
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.fetch(new FetchResultCallback() {
@@ -451,11 +464,11 @@ protected Asset setTags(String[] tags) {
      *
      * @return the asset
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.includeDimension();
@@ -469,15 +482,17 @@ public Asset includeDimension() {
     /**
      * Add param asset.
      *
-     * @param paramKey   the param key
-     * @param paramValue the param value
+     * @param paramKey
+     *         the param key
+     * @param paramValue
+     *         the param value
      * @return the asset
      *
-     *         
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.addParam();
@@ -493,12 +508,12 @@ public Asset addParam(@NotNull String paramKey, @NotNull String paramValue) {
      *
      * @return the asset
      *
-     * 
-     *         
- *
- * Example :
* - *
+     * 
+ *
+ * Example :
+ * + *
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.includeFallback();
@@ -514,11 +529,11 @@ public Asset includeFallback() {
      *
      * @return {@link Asset} object, so you can chain this call. 
* - *
- *
- * Example :
+ *
+ *
+ * Example :
* - *
+     * 
      *         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
      *         Asset asset = stack.asset(asset_uid);
      *         asset.includeBranch();
@@ -532,7 +547,8 @@ public Asset includeBranch() {
     /**
      * Fetch.
      *
-     * @param callback the callback
+     * @param callback
+     *         the callback
      */
     public void fetch(FetchResultCallback callback) {
         urlQueries.put(ENVIRONMENT, this.headers.get(ENVIRONMENT));
@@ -540,7 +556,7 @@ public void fetch(FetchResultCallback callback) {
     }
 
     private void fetchFromNetwork(String url, JSONObject urlQueries, LinkedHashMap headers,
-            FetchResultCallback callback) {
+                                  FetchResultCallback callback) {
         if (callback != null) {
             HashMap urlParams = getUrlParams(urlQueries);
             new CSBackgroundTask(this, stackInstance, Constants.FETCHASSETS, url, headers, urlParams,
diff --git a/src/main/java/com/contentstack/sdk/Constants.java b/src/main/java/com/contentstack/sdk/Constants.java
index fa64ae5f..3904b5e9 100644
--- a/src/main/java/com/contentstack/sdk/Constants.java
+++ b/src/main/java/com/contentstack/sdk/Constants.java
@@ -7,12 +7,16 @@
 import java.util.logging.Logger;
 
 /**
- * The type Constants.
+ * The type Constants for Internal Uses.
+ *
+ * @author Shailesh Mishra
+ * @version 1.0.0
+ * @since 01-11-2017
  */
 public class Constants {
 
     private static final Logger logger = Logger.getLogger(Constants.class.getSimpleName());
-    protected static final String SDK_VERSION = "1.10.0";
+    protected static final String SDK_VERSION = "1.10.1";
     protected static final String ENVIRONMENT = "environment";
     protected static final String CONTENT_TYPE_UID = "content_type_uid";
     protected static final String SYNCHRONISATION = "stacks/sync";
diff --git a/src/main/java/com/contentstack/sdk/ContentType.java b/src/main/java/com/contentstack/sdk/ContentType.java
index ab320028..fe533ec9 100644
--- a/src/main/java/com/contentstack/sdk/ContentType.java
+++ b/src/main/java/com/contentstack/sdk/ContentType.java
@@ -9,7 +9,13 @@
 import java.util.logging.Logger;
 
 /**
- * The type Content type.
+ * ContentType
+ * This call returns information of a specific content type. It returns the content type schema, but does not include
+ * its entries.
+ *
+ * @author Shailesh Mishra
+ * @version 1.0.0
+ * @since 01-11-2017
  */
 public class ContentType {
 
@@ -58,9 +64,11 @@ public void removeHeader(String headerKey) {
     }
 
     /**
-     * An entry is the actual piece of content created using one of the defined content types.
+     * An Entry is the
+     * actual piece of content created using one of the defined content types.
      * 

- * The Get a single entry request fetches a particular entry of a content type. + * You can now pass the branch header in the API request to fetch or manage modules located within specific branches + * of the stack. * * @param entryUid * the entry unique ID of the entry that you want to fetch. @@ -112,11 +120,11 @@ public Query query() { * Fetch. * * @param params - * the params + * the params of type {@link JSONObject} * @param callback - * the callback + * the callback of type {@link ContentTypesCallback} */ - public void fetch(@NotNull JSONObject params, final ContentTypesCallback callback) { + public void fetch(@NotNull JSONObject params, final ContentTypesCallback callback) throws IllegalAccessException { String urlString = "content_types/" + contentTypeUid; Iterator keys = params.keys(); while (keys.hasNext()) { @@ -125,12 +133,8 @@ public void fetch(@NotNull JSONObject params, final ContentTypesCallback callbac params.put(key, value); } params.put("environment", headers.get("environment")); - if (contentTypeUid != null && !contentTypeUid.isEmpty()) { - try { - throw new IllegalAccessException("contentTypeUid is required"); - } catch (Exception e) { - logger.warning("contentTypeUid is required"); - } + if (contentTypeUid == null || contentTypeUid.isEmpty()) { + throw new IllegalAccessException("contentTypeUid is required"); } fetchContentTypes(urlString, params, headers, callback); } diff --git a/src/main/java/com/contentstack/sdk/Query.java b/src/main/java/com/contentstack/sdk/Query.java index ffda5510..1a44b912 100644 --- a/src/main/java/com/contentstack/sdk/Query.java +++ b/src/main/java/com/contentstack/sdk/Query.java @@ -10,11 +10,21 @@ import static com.contentstack.sdk.Constants.*; + /** + * Queries * Contentstack provides certain queries that you can use to fetch filtered results. You can use queries for Entries and * Assets API requests. + *

+ * You can now pass the branch header in the API request to fetch or manage modules located within specific branches of + * the stack. + *

+ * Note Branches is a plan-based feature that is available only in the new Contentstack interface. + * + * @author Shailesh Mishra + * @version 1.0.0 + * @since 01-11-2017 */ - public class Query implements INotifyClass { protected static final Logger logger = Logger.getLogger(Query.class.getSimpleName()); @@ -55,16 +65,12 @@ protected void setContentTypeInstance(ContentType contentTypeInstance) { * @param value * header value against given header name.
* - * - *
- *
* Example :
- * - *

-     *                                      Stack stack = Contentstack.stack( "apiKey", "deliveryToken", "environment");
-     *                                      Query csQuery = stack.contentType("contentTypeUid").query();
- * csQuery.setHeader("custom_key", "custom_value"); - *
+ *

+ *

 Stack stack = Contentstack.stack( "apiKey", "deliveryToken", "environment");
+     *                                 Query csQuery = stack.contentType("contentTypeUid").query();
+     *                                 csQuery.setHeader("custom_key", "custom_value");
+     *                                 
*/ public void setHeader(@NotNull String key, @NotNull String value) { if (!key.isEmpty() && !value.isEmpty()) { @@ -83,10 +89,10 @@ public void setHeader(@NotNull String key, @NotNull String value) { * Example :
* *
-     *                                    Stack stack = Contentstack..stack( "apiKey", "deliveryToken", "environment");
-     *                                    Query csQuery = stack.contentType("contentTypeUid").query();
- * csQuery.removeHeader("custom_key"); - *
+ * Stack stack = Contentstack..stack( "apiKey", "deliveryToken", "environment"); + * Query csQuery = stack.contentType("contentTypeUid").query();
+ * csQuery.removeHeader("custom_key"); + *
*/ public void removeHeader(@NotNull String key) { if (!key.isEmpty()) { diff --git a/src/test/java/com/contentstack/sdk/TestContentType.java b/src/test/java/com/contentstack/sdk/TestContentType.java index b80e95a5..892353e9 100644 --- a/src/test/java/com/contentstack/sdk/TestContentType.java +++ b/src/test/java/com/contentstack/sdk/TestContentType.java @@ -83,7 +83,7 @@ void testQueryInstance() { } @Test - void testContentTypeFetch() { + void testContentTypeFetch() throws IllegalAccessException { ContentType contentType = stack.contentType("product"); JSONObject paramObj = new JSONObject(); paramObj.put("ctKeyOne", "ctKeyValue1"); @@ -98,7 +98,7 @@ public void onCompletion(ContentTypesModel model, Error error) { } @Test - void testContentTypesFetch() { + void testContentTypesFetch() throws IllegalAccessException { ContentType contentType = stack.contentType("product"); JSONObject paramObj = new JSONObject(); paramObj.put("ctKeyOne", "ctKeyValue1"); @@ -112,11 +112,5 @@ public void onCompletion(ContentTypesModel model, Error error) { }); } - @Test - void toCoverageCheckHeader() { - Map mapHeader = new HashMap<>(); - CSBackgroundTask backgroundTask = new CSBackgroundTask(); - backgroundTask.checkHeader(mapHeader); - } }