From a5e841d595604ac358a05c36dc418d78bf4a62da Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 6 Feb 2024 19:06:40 +0530 Subject: [PATCH 1/4] v3.14.0: function support added - initial sequential sync - sequential sync --- build.gradle | 1 - contentstack/build.gradle | 5 +- .../com/contentstack/sdk/SDKConstant.java | 2 +- .../main/java/com/contentstack/sdk/Stack.java | 85 ++++++++++++++----- gradle/wrapper/gradle-wrapper.properties | 2 - 5 files changed, 65 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index dfe2f5ec..bd0077b2 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,6 @@ buildscript { } dependencies { - //classpath "com.android.tools.build:gradle:8.2.1" //8.2.1 classpath 'com.android.tools.build:gradle:7.4.2' classpath 'io.github.gradle-nexus:publish-plugin:2.0.0-rc-1' classpath "org.jacoco:org.jacoco.core:$jacoco_version" diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 06aa4346..d22083ec 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -10,7 +10,7 @@ android.buildFeatures.buildConfig true mavenPublishing { publishToMavenCentral(SonatypeHost.DEFAULT) signAllPublications() - coordinates("com.contentstack.sdk", "android", "3.13.0") + coordinates("com.contentstack.sdk", "android", "3.14.0") pom { name = "contentstack-android" @@ -132,14 +132,12 @@ android { } configurations { archives } dependencies { - def multidex = "2.0.1" def volley = "1.2.1" def junit = "4.13.2" configurations.configureEach { resolutionStrategy.force 'com.android.support:support-annotations:23.1.0' } implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "com.android.volley:volley:$volley" implementation "junit:junit:$junit" - // For AGP 7.4+ coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test:core:1.5.0' @@ -158,6 +156,5 @@ tasks.register('createJar', Jar) { archivesBaseName = "contentstack.jar" from('build/contentstack-jar/') include 'com/contentstack/' - //include 'META-INF/' } createJar.dependsOn(clearJar, unzip, build) diff --git a/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java b/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java index 1dbf54d2..7359aab0 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java +++ b/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java @@ -9,7 +9,7 @@ public class SDKConstant { public static final boolean debug = false; public static boolean IS_NETWORK_AVAILABLE = true; public static String PROTOCOL = "https://"; - public static String SDK_VERSION = "3.13.0"; + public static String SDK_VERSION = "3.14.0"; public final static int NO_NETWORK_CONNECTION = 408; public final static int TimeOutDuration = 30000; // timeout in millisecond public final static int NumRetry = 0; diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index d5bcb87b..f083bf67 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -25,7 +25,7 @@ /** * To fetch stack level information of your application from Contentstack server. *

- * Created by Shailesh Mishra. + * Created by ishaileshmishra. * Contentstack pvt Ltd */ public class Stack implements INotifyClass { @@ -51,7 +51,7 @@ protected Stack() { } protected Stack(String apiKey) { - if (apiKey==null){ + if (apiKey == null) { Objects.requireNonNull("Please provide a valid ApiKey"); } this.stackApiKey = apiKey; @@ -291,17 +291,17 @@ private String getImageUrl() { * This call returns comprehensive information of all the content types available in a particular stack in your account. *

Example :
*

-     *                                                                                                                                                                                                                                                                                                                                                                                                 JSONObject params = new JSONObject();
-     *                                                                                                                                                                                                                                                                                                                                                                                                 params.put("include_snippet_schema", true);
-     *                                                                                                                                                                                                                                                                                                                                                                                                 params.put("limit", 3);
-     *                                                                                                                                                                                                                                                                                                                                                                                                 stack.getContentTypes(params, new ContentTypesCallback() {
-     *                                                                                                                                                                                                                                                                                                                                                                                                 @Override  public void onCompletion(ContentTypesModel contentTypesModel, Error error) {
-     *                                                                                                                                                                                                                                                                                                                                                                                                 if (error == null){
-     *                                                                                                                                                                                                                                                                                                                                                                                                 // do your stuff.
-     *                                                                                                                                                                                                                                                                                                                                                                                                 }
-     *                                                                                                                                                                                                                                                                                                                                                                                                 }
-     *                                                                                                                                                                                                                                                                                                                                                                                                 });
-     *                                                                                                                                                                                                                                                                                                                                                                                                 
+ * JSONObject params = new JSONObject(); + * params.put("include_snippet_schema", true); + * params.put("limit", 3); + * stack.getContentTypes(params, new ContentTypesCallback() { + * @Override public void onCompletion(ContentTypesModel contentTypesModel, Error error) { + * if (error == null){ + * // do your stuff. + * } + * } + * }); + * */ public void getContentTypes(JSONObject params, final ContentTypesCallback callback) { try { @@ -352,12 +352,12 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap *

Example :
*
      *
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                             stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {}
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
+ * @deprecated sync is deprecated Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); + * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} + * */ - public void sync(SyncResultCallBack syncCallBack) { + @Deprecated public void sync(SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); this.syncParams.put("init", true); @@ -384,7 +384,9 @@ public void sync(SyncResultCallBack syncCallBack) { * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} * * + * @deprecated This method is deprecated. Use {@link #initSeqSync(SyncResultCallBack)} instead. */ + @Deprecated public void syncPaginationToken(String paginationToken, SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); @@ -404,8 +406,9 @@ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncC * and the details of the content that was deleted or updated. *

Example :
*
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
+ @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ + @Deprecated public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); @@ -416,6 +419,41 @@ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { this.requestSync(syncCallBack); } + + /** + * The initSeqSync is used to make initial call to receive data in sequential pattern, based on sequence id + * + * @param syncCallBack the callback that contains response or error + */ + public void initSeqSync(SyncResultCallBack syncCallBack) { + try { + this.syncParams = new JSONObject(); + this.syncParams.put("seq_id", true); + } catch (JSONException e) { + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); + } + this.requestSync(syncCallBack); + } + + + /** + * Use the sequential token to receive data in sequential manner, based on sequence id + * + * @param seqId the sequence id + * @param syncCallBack the callback that contains response or error + */ + public void seqSync(String seqId, SyncResultCallBack syncCallBack) { + Objects.requireNonNull(seqId, "SequenceId should not be null"); + try { + this.syncParams = new JSONObject(); + this.syncParams.put("seq_id", seqId); + } catch (JSONException e) { + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); + } + this.requestSync(syncCallBack); + } + + /** * @param fromDate Enter the start date for initial sync. * @param syncCallBack Returns callback for sync result. @@ -425,8 +463,8 @@ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { * *

Example :
*
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stack.syncFromDate(start_date, new SyncResultCallBack()) { }
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
+ * stack.syncFromDate(start_date, new SyncResultCallBack()) { } + * */ public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { String startFromDate = convertUTCToISO(fromDate); @@ -475,7 +513,9 @@ private String convertUTCToISO(Date date) { * To do this, use syncLocale and specify the locale code as its value. * However, if you do this, the subsequent syncs will only include the entries of the specified locales. * + * @deprecated This method is deprecated. Use {@link #syncLocale(String, SyncResultCallBack)} ()} instead. */ + @Deprecated() public void syncLocale(Language language, SyncResultCallBack syncCallBack) { String localeCode = getLanguageCode(language); try { @@ -497,8 +537,8 @@ public void syncLocale(Language language, SyncResultCallBack syncCallBack) { * */ public void syncLocale(String localeCode, SyncResultCallBack syncCallBack) { - if (localeCode==null){ - Objects.requireNonNull("localeCode can not be null"); + if (localeCode == null) { + Objects.requireNonNull("Locale code can not be null"); } try { this.syncParams = new JSONObject(); @@ -563,6 +603,7 @@ private String getLanguageCode(Language language) { * */ + @Deprecated public void sync(String contentType, Date fromDate, Language language, PublishType type, SyncResultCallBack syncCallBack) { String locale = getLanguageCode(language); sync(contentType, fromDate, locale, type, syncCallBack); diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6b0e6c07..5c6f89db 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -#distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip -#distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip networkTimeout=10000 validateDistributionUrl=true From 080cc0586015e93cc71ea926b5e0bf5e301bfd37 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 6 Feb 2024 19:18:56 +0530 Subject: [PATCH 2/4] v3.14.0: function support added - initial sequential sync - sequential sync --- contentstack/build.gradle | 2 +- .../java/com/contentstack/sdk/SyncStack.java | 29 +++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index d22083ec..8b2c3e67 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -10,7 +10,7 @@ android.buildFeatures.buildConfig true mavenPublishing { publishToMavenCentral(SonatypeHost.DEFAULT) signAllPublications() - coordinates("com.contentstack.sdk", "android", "3.14.0") + coordinates("com.contentstack.sdk", "android", "3.14.0-SNAPSHOT") pom { name = "contentstack-android" diff --git a/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java b/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java index 96551bb4..d8cee54b 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java @@ -18,10 +18,24 @@ public class SyncStack { private int count; private String URL; private String pagination_token; - private String sync_token; + private String syncToken; private ArrayList syncItems; + private String sequentialToken; + /** + * Gets sequential token based on sync response + * + * @return sequentialToken + */ + public String getSequentialToken() { + return sequentialToken; + } + + public void setSequentialToken(String sequentialToken) { + this.sequentialToken = sequentialToken; + } + /** * Gets url. * @@ -82,7 +96,7 @@ public String getPaginationToken() { * @return the sync token */ public String getSyncToken() { - return this.sync_token; + return this.syncToken; } /** @@ -130,12 +144,17 @@ protected void setJSON(JSONObject jsonobject) { if (receiveJson.has("pagination_token")) { this.pagination_token = receiveJson.optString("pagination_token"); } else { - this.sync_token = null; + this.syncToken = null; } if (receiveJson.has("sync_token")) { - this.sync_token = receiveJson.optString("sync_token"); + this.syncToken = receiveJson.optString("sync_token"); + } else { + this.syncToken = null; + } + if (receiveJson.has("last_seq_id")) { + this.sequentialToken = receiveJson.optString("last_seq_id"); } else { - this.sync_token = null; + this.sequentialToken = null; } } } catch (Exception e) { From b11ea95254502e2f1eb97b8b8fce818345b1347f Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Thu, 8 Feb 2024 18:15:14 +0530 Subject: [PATCH 3/4] v3.14.0: function support added - initial sequential sync - sequential sync --- contentstack/build.gradle | 2 +- .../main/java/com/contentstack/sdk/Stack.java | 44 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 8b2c3e67..d22083ec 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -10,7 +10,7 @@ android.buildFeatures.buildConfig true mavenPublishing { publishToMavenCentral(SonatypeHost.DEFAULT) signAllPublications() - coordinates("com.contentstack.sdk", "android", "3.14.0-SNAPSHOT") + coordinates("com.contentstack.sdk", "android", "3.14.0") pom { name = "contentstack-android" diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index f083bf67..e57c5a5f 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -291,17 +291,17 @@ private String getImageUrl() { * This call returns comprehensive information of all the content types available in a particular stack in your account. *

Example :
*
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 JSONObject params = new JSONObject();
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 params.put("include_snippet_schema", true);
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 params.put("limit", 3);
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 stack.getContentTypes(params, new ContentTypesCallback() {
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 @Override  public void onCompletion(ContentTypesModel contentTypesModel, Error error) {
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 if (error == null){
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 // do your stuff.
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 }
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 }
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 });
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
+ * JSONObject params = new JSONObject(); + * params.put("include_snippet_schema", true); + * params.put("limit", 3); + * stack.getContentTypes(params, new ContentTypesCallback() { + * @Override public void onCompletion(ContentTypesModel contentTypesModel, Error error) { + * if (error == null){ + * // do your stuff. + * } + * } + * }); + * */ public void getContentTypes(JSONObject params, final ContentTypesCallback callback) { try { @@ -348,16 +348,15 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap * It returns all the published entries and assets of the specified stack in response. * The response also contains a sync token, which you need to store, * since this token is used to get subsequent delta updates later. - * - *

Example :
*
-     *
-     * @deprecated sync is deprecated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {}
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
+ *

Example :
+ * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); + * + * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ - @Deprecated public void sync(SyncResultCallBack syncCallBack) { + @Deprecated + public void sync(SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); this.syncParams.put("init", true); @@ -384,7 +383,7 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} * * - * @deprecated This method is deprecated. Use {@link #initSeqSync(SyncResultCallBack)} instead. + * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ @Deprecated public void syncPaginationToken(String paginationToken, SyncResultCallBack syncCallBack) { @@ -406,7 +405,7 @@ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncC * and the details of the content that was deleted or updated. *

Example :
*
-     @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
+ * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ @Deprecated public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { @@ -428,6 +427,7 @@ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { public void initSeqSync(SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); + this.syncParams.put("init", true); this.syncParams.put("seq_id", true); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); @@ -463,8 +463,8 @@ public void seqSync(String seqId, SyncResultCallBack syncCallBack) { * *

Example :
*
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                stack.syncFromDate(start_date, new SyncResultCallBack()) { }
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
+ * stack.syncFromDate(start_date, new SyncResultCallBack()) { } + * */ public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { String startFromDate = convertUTCToISO(fromDate); From 9131a2b4c2d07d7c3a816275a682ee5d5fbe4045 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Thu, 8 Feb 2024 19:05:32 +0530 Subject: [PATCH 4/4] v3.14.0: function support added - initial sequential sync - sequential sync --- CHANGELOG.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0dd00a9..bf7bb4a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # CHANGELOG +## Version 3.14.0 + +### Date: 10-Feb-2024 + +- support of new sync api +- initSeqSync in stack class +- seqSync in stack class + +--- + +## Version 3.13.0 + +### Date: 02-Feb-2024 + +- Fixed dependency installing issue +- Fixed Download Issue +- Error Status Code added +- Support of early access headers + +--- ## Version 3.12.4