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 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..e57c5a5f 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 { @@ -348,15 +348,14 @@ 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. - * - *
- * - * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); - * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} - *+ *
- *+ * @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 +418,42 @@ 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("init", true); + 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) { * *
- * 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/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