From a5e841d595604ac358a05c36dc418d78bf4a62da Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 6 Feb 2024 19:06:40 +0530 Subject: [PATCH 01/43] 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 02/43] 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 03/43] 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 04/43] 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 From d2eded97425130e11334ae97426b4ae337d04df0 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 12:07:41 +0530 Subject: [PATCH 05/43] Create publish-snapshot.yaml --- .github/workflows/publish-snapshot.yaml | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/publish-snapshot.yaml diff --git a/.github/workflows/publish-snapshot.yaml b/.github/workflows/publish-snapshot.yaml new file mode 100644 index 00000000..6ee1af6f --- /dev/null +++ b/.github/workflows/publish-snapshot.yaml @@ -0,0 +1,31 @@ +name: Publish - Snapshot + +on: + push: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout project sources + uses: actions/checkout@v3 + - name: Check whether the version is a snapshot + run: | + if grep -q "\-SNAPSHOT" ./contentstack/build.gradle + then + : + else + exit 1 + fi + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Publish the SDK - Snapshot + run: | + ./gradlew clean build + ./gradlew publishAllPublicationsToMavenCentralRepository + env: + ORG_GRADLE_PROJECT_mavenCentralUsername=${{ secrets.mavenCentralUsername }} + ORG_GRADLE_PROJECT_mavenCentralPassword=${{ secrets.mavenCentralPassword }} + ORG_GRADLE_PROJECT_signingInMemoryKey=${{ secrets.signingInMemoryKey }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId=${{ secrets.signingInMemoryKeyId }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword=${{ secrets.signingInMemoryKeyPassword }} From 3acb1249cf5241da0d93219e21f367bb89ad2030 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 12:07:58 +0530 Subject: [PATCH 06/43] Rename publish-snapshot.yaml to publish-snapshot.yml --- .github/workflows/{publish-snapshot.yaml => publish-snapshot.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{publish-snapshot.yaml => publish-snapshot.yml} (100%) diff --git a/.github/workflows/publish-snapshot.yaml b/.github/workflows/publish-snapshot.yml similarity index 100% rename from .github/workflows/publish-snapshot.yaml rename to .github/workflows/publish-snapshot.yml From 7c0b706d9c739d31487ce65751e9dac58c4c408e Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 12:08:22 +0530 Subject: [PATCH 07/43] Create publish-release.yml --- .github/workflows/publish-release.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000..e6326026 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,26 @@ +name: Publish - Release + +on: + release: + types: [released] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout project sources + uses: actions/checkout@v3 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Gradle build and clean + run: | + ./gradlew clean build + - name: Publish the SDK + run: | + ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache + env: + ORG_GRADLE_PROJECT_mavenCentralUsername=${{ secrets.mavenCentralUsername }} + ORG_GRADLE_PROJECT_mavenCentralPassword=${{ secrets.mavenCentralPassword }} + ORG_GRADLE_PROJECT_signingInMemoryKey=${{ secrets.signingInMemoryKey }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId=${{ secrets.signingInMemoryKeyId }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword=${{ secrets.signingInMemoryKeyPassword }} From 681b78b6bdabb788fdcca811f60028751564b92c Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 12:11:31 +0530 Subject: [PATCH 08/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 6ee1af6f..0b8d6a5f 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -24,8 +24,8 @@ jobs: ./gradlew clean build ./gradlew publishAllPublicationsToMavenCentralRepository env: - ORG_GRADLE_PROJECT_mavenCentralUsername=${{ secrets.mavenCentralUsername }} - ORG_GRADLE_PROJECT_mavenCentralPassword=${{ secrets.mavenCentralPassword }} - ORG_GRADLE_PROJECT_signingInMemoryKey=${{ secrets.signingInMemoryKey }} - ORG_GRADLE_PROJECT_signingInMemoryKeyId=${{ secrets.signingInMemoryKeyId }} - ORG_GRADLE_PROJECT_signingInMemoryKeyPassword=${{ secrets.signingInMemoryKeyPassword }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.mavenCentralUsername }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.mavenCentralPassword }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.signingInMemoryKey }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.signingInMemoryKeyId }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.signingInMemoryKeyPassword }} From e2d4d7b33ad41ed8180dacdf4424cb3080114501 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 12:11:57 +0530 Subject: [PATCH 09/43] Update publish-release.yml --- .github/workflows/publish-release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index e6326026..daa8c273 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -19,8 +19,8 @@ jobs: run: | ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache env: - ORG_GRADLE_PROJECT_mavenCentralUsername=${{ secrets.mavenCentralUsername }} - ORG_GRADLE_PROJECT_mavenCentralPassword=${{ secrets.mavenCentralPassword }} - ORG_GRADLE_PROJECT_signingInMemoryKey=${{ secrets.signingInMemoryKey }} - ORG_GRADLE_PROJECT_signingInMemoryKeyId=${{ secrets.signingInMemoryKeyId }} - ORG_GRADLE_PROJECT_signingInMemoryKeyPassword=${{ secrets.signingInMemoryKeyPassword }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.mavenCentralUsername }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.mavenCentralPassword }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.signingInMemoryKey }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.signingInMemoryKeyId }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.signingInMemoryKeyPassword }} From 323ff4452cf90d43585899f57b927d54df6e5ff9 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Mon, 12 Feb 2024 15:31:45 +0530 Subject: [PATCH 10/43] v3.14.0: function support added - initial sequential sync - sequential sync --- contentstack/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From b312ccb2394b2de564c98b238e399575530d5bd9 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 15:40:47 +0530 Subject: [PATCH 11/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 0b8d6a5f..889aa6bd 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -19,9 +19,11 @@ jobs: fi - name: Setup Gradle uses: gradle/gradle-build-action@v2 - - name: Publish the SDK - Snapshot + - name: Build the SDK - Snapshot run: | ./gradlew clean build + - name: Publish the SDK - Snapshot + run: | ./gradlew publishAllPublicationsToMavenCentralRepository env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.mavenCentralUsername }} From e8d445c57c63cc06e3069c8728c6dc24c7aa2c9a Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 15:52:35 +0530 Subject: [PATCH 12/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 889aa6bd..b5acc24c 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -19,6 +19,8 @@ jobs: fi - name: Setup Gradle uses: gradle/gradle-build-action@v2 + - name: Setup local.properties + run: echo "sdk.dir=$ANDROID_HOME" >> local.properties - name: Build the SDK - Snapshot run: | ./gradlew clean build From 185a2c7e185a81bb757601f59d007edc5704bbd3 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 16:03:56 +0530 Subject: [PATCH 13/43] Update sca-scan.yml --- .github/workflows/sca-scan.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml index 7fa03ee3..e102fcf3 100644 --- a/.github/workflows/sca-scan.yml +++ b/.github/workflows/sca-scan.yml @@ -7,6 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master + - name: Setup local.properties + run: echo "sdk.dir=$ANDROID_HOME" >> local.properties - uses: snyk/actions/setup@master - run: snyk test env: From 665bf64a9bf5502a362d454ce00be25ef22a2859 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 17:48:32 +0530 Subject: [PATCH 14/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index b5acc24c..974b390c 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -20,7 +20,16 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Setup local.properties - run: echo "sdk.dir=$ANDROID_HOME" >> local.properties + run: | + cat << EOF >> local.properties + sdk.dir=$ANDROID_HOME + host="${{ secrets.HOST }}" + APIKey="${{ secrets.API_KEY }}" + deliveryToken="${{ secrets.DELIVERY_TOKEN }}" + environment="${{ secrets.ENVIRONMENT }}" + contentType="${{ secrets.CONTENT_TYPE }}" + assetUid="${{ secrets.ASSET_UID }}" + EOF - name: Build the SDK - Snapshot run: | ./gradlew clean build From 7938f7c790e4c96b6019e5cd62231c3be45820ee Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Mon, 12 Feb 2024 17:53:26 +0530 Subject: [PATCH 15/43] v3.14.0: function support added - initial sequential sync - sequential sync --- gradle.properties | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 gradle.properties diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..8a69cd84 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +android.useAndroidX=true +android.enableJetifier=true +android.enableR8.fullMode=false From a5d76b4e111f0bea3056fdf7c9cf4ff37e2bb992 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Mon, 12 Feb 2024 17:55:05 +0530 Subject: [PATCH 16/43] v3.14.0: function support added - initial sequential sync - sequential sync --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index 8a69cd84..f05239f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ android.useAndroidX=true android.enableJetifier=true android.enableR8.fullMode=false +### From fb6e92d9b590e805d20392c62cb42e80389ec5b8 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 18:04:23 +0530 Subject: [PATCH 17/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 974b390c..a24eed67 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -17,6 +17,10 @@ jobs: else exit 1 fi + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Setup local.properties From 8d43e49115f96530dcd67d07ebc31262803a3b68 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Mon, 12 Feb 2024 18:11:45 +0530 Subject: [PATCH 18/43] v3.14.0: function support added - initial sequential sync - sequential sync --- contentstack/build.gradle | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 8b2c3e67..b85db6f3 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -41,20 +41,30 @@ mavenPublishing { } -tasks.register('jacocoTestReport', JacocoReport) { - dependsOn['testDebugUnitTest', 'createDebugCoverageReport'] - reports { - html.enabled = true - } - afterEvaluate { - classDirectories.setFrom(files(classDirectories.files.collect { - fileTree(dir: it, exclude: '**com/contentstack/okhttp**') - fileTree(dir: it, exclude: '**com/contentstack/okio**') - fileTree(dir: it, exclude: '**com/contentstack/txtmark**') - })) +//tasks.register('jacocoTestReport', JacocoReport) { +// dependsOn['testDebugUnitTest', 'createDebugCoverageReport'] +// reports { +// html.enabled = true +// } +// afterEvaluate { +// classDirectories.setFrom(files(classDirectories.files.collect { +// fileTree(dir: it, exclude: '**com/contentstack/okhttp**') +// fileTree(dir: it, exclude: '**com/contentstack/okio**') +// fileTree(dir: it, exclude: '**com/contentstack/txtmark**') +// })) +// } +//} + +junitJacoco { + jacocoVersion = '0.8.4' // type String + includeInstrumentationCoverageInMergedReport = true // type boolean + tasks.withType(Test) { + jacoco.includeNoLocationClasses = true + jacoco.excludes = ['jdk.internal.*'] } } + android { //namespace "com.contentstack.sdk" packagingOptions { From 30e9ae57de48a2c07807062942264103493b8037 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Mon, 12 Feb 2024 18:12:40 +0530 Subject: [PATCH 19/43] v3.14.0: function support added - initial sequential sync - sequential sync --- contentstack/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index b85db6f3..ea2759c2 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -40,7 +40,6 @@ mavenPublishing { } } - //tasks.register('jacocoTestReport', JacocoReport) { // dependsOn['testDebugUnitTest', 'createDebugCoverageReport'] // reports { From 018ec83a104ba1646dfb1d1d656c59e7801c49a6 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Mon, 12 Feb 2024 18:14:59 +0530 Subject: [PATCH 20/43] v3.14.0: function support added - initial sequential sync - sequential sync --- contentstack/build.gradle | 9 --------- 1 file changed, 9 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index ea2759c2..243f0279 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -54,15 +54,6 @@ mavenPublishing { // } //} -junitJacoco { - jacocoVersion = '0.8.4' // type String - includeInstrumentationCoverageInMergedReport = true // type boolean - tasks.withType(Test) { - jacoco.includeNoLocationClasses = true - jacoco.excludes = ['jdk.internal.*'] - } -} - android { //namespace "com.contentstack.sdk" From 1faadceacb54429539fd033b719db15d1a60a035 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 18:23:18 +0530 Subject: [PATCH 21/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index a24eed67..c8ccd372 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -19,7 +19,7 @@ jobs: fi - uses: actions/setup-java@v4 with: - distribution: 'temurin' + distribution: 'oracle' java-version: '11' - name: Setup Gradle uses: gradle/gradle-build-action@v2 From c23575e46d34914a32bd61decc0765cd27a9ad81 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 18:26:29 +0530 Subject: [PATCH 22/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index c8ccd372..41af6f07 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -19,7 +19,7 @@ jobs: fi - uses: actions/setup-java@v4 with: - distribution: 'oracle' + distribution: 'microsoft' java-version: '11' - name: Setup Gradle uses: gradle/gradle-build-action@v2 From b4198aff769bc50e034478eddbd9f7e7c780e5bd Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 18:28:42 +0530 Subject: [PATCH 23/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 41af6f07..c1eeb416 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -19,8 +19,8 @@ jobs: fi - uses: actions/setup-java@v4 with: - distribution: 'microsoft' - java-version: '11' + distribution: 'temurin' + java-version: '8' - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Setup local.properties From a709fb48d4ab2bcc3a8544927d1846009eef12ba Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 18:30:37 +0530 Subject: [PATCH 24/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index c1eeb416..5cb45809 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -23,6 +23,8 @@ jobs: java-version: '8' - name: Setup Gradle uses: gradle/gradle-build-action@v2 + with: + gradle-version: 7.4.2 - name: Setup local.properties run: | cat << EOF >> local.properties From 157f5ff79c7cf281445d9c55b6a807196a9bc73f Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Mon, 12 Feb 2024 18:31:43 +0530 Subject: [PATCH 25/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 5cb45809..a24eed67 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -20,11 +20,9 @@ jobs: - uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '8' + java-version: '11' - name: Setup Gradle uses: gradle/gradle-build-action@v2 - with: - gradle-version: 7.4.2 - name: Setup local.properties run: | cat << EOF >> local.properties From 61ae6ea9b219dc7f2f786f3f43093a1722ab01d4 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Mon, 12 Feb 2024 18:39:02 +0530 Subject: [PATCH 26/43] v3.14.0: function support added - initial sequential sync - sequential sync --- contentstack/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 243f0279..b0c16b76 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -73,6 +73,7 @@ android { unitTests.all { jacoco { includeNoLocationClasses = true + excludes = ['jdk.internal.*'] } } } From 683ffe78f0d9bffcf9b72ba3f7b4287b9f473673 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Mon, 12 Feb 2024 18:39:46 +0530 Subject: [PATCH 27/43] v3.14.0: function support added - initial sequential sync - sequential sync --- contentstack/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index b0c16b76..761cb08b 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -69,6 +69,7 @@ android { exclude("META-INF/*.kotlin_module") } + testOptions { unitTests.all { jacoco { From 3b8e6ef76a601d93a2abcb3d6c26a80314569827 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 13 Feb 2024 11:10:43 +0530 Subject: [PATCH 28/43] Update sca-scan.yml --- .github/workflows/sca-scan.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml index e102fcf3..482bc0f7 100644 --- a/.github/workflows/sca-scan.yml +++ b/.github/workflows/sca-scan.yml @@ -8,7 +8,16 @@ jobs: steps: - uses: actions/checkout@master - name: Setup local.properties - run: echo "sdk.dir=$ANDROID_HOME" >> local.properties + run: | + cat << EOF >> local.properties + sdk.dir=$ANDROID_HOME + host="${{ secrets.HOST }}" + APIKey="${{ secrets.API_KEY }}" + deliveryToken="${{ secrets.DELIVERY_TOKEN }}" + environment="${{ secrets.ENVIRONMENT }}" + contentType="${{ secrets.CONTENT_TYPE }}" + assetUid="${{ secrets.ASSET_UID }}" + EOF - uses: snyk/actions/setup@master - run: snyk test env: From ceb22db5fac64f28049f590654b153985ee8aacb Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 13 Feb 2024 11:52:36 +0530 Subject: [PATCH 29/43] Update publish-snapshot.yml --- .github/workflows/publish-snapshot.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index a24eed67..974b390c 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -17,10 +17,6 @@ jobs: else exit 1 fi - - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '11' - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Setup local.properties From ec3c9ae47e466e39d154d09220043bed54ad5385 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 13 Feb 2024 12:47:34 +0530 Subject: [PATCH 30/43] v3.14.0: function support added - initial sequential sync - sequential sync --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index f05239f9..7a0cdd98 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,5 @@ android.useAndroidX=true android.enableJetifier=true android.enableR8.fullMode=false +org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m ### From 8d1217d8b0b676039063e6fc61a89b6839635a2b Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 13 Feb 2024 12:48:00 +0530 Subject: [PATCH 31/43] v3.14.0: function support added - initial sequential sync - sequential sync --- gradle.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 7a0cdd98..f96ff2e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,3 @@ android.useAndroidX=true android.enableJetifier=true android.enableR8.fullMode=false org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m -### From 0483a0b163431affd65d43ab3ab7721b482f4abc Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 13 Feb 2024 13:00:09 +0530 Subject: [PATCH 32/43] Update codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 9d241b91..8278860f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -35,6 +35,17 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + - name: Setup local.properties + run: | + cat << EOF >> local.properties + sdk.dir=$ANDROID_HOME + host="${{ secrets.HOST }}" + APIKey="${{ secrets.API_KEY }}" + deliveryToken="${{ secrets.DELIVERY_TOKEN }}" + environment="${{ secrets.ENVIRONMENT }}" + contentType="${{ secrets.CONTENT_TYPE }}" + assetUid="${{ secrets.ASSET_UID }}" + EOF # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL From 23e0420dec70e025638b874d05609702c378821a Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 13 Feb 2024 13:01:45 +0530 Subject: [PATCH 33/43] Update publish-release.yml --- .github/workflows/publish-release.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index daa8c273..7f77e123 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -12,6 +12,17 @@ jobs: uses: actions/checkout@v3 - name: Setup Gradle uses: gradle/gradle-build-action@v2 + - name: Setup local.properties + run: | + cat << EOF >> local.properties + sdk.dir=$ANDROID_HOME + host="${{ secrets.HOST }}" + APIKey="${{ secrets.API_KEY }}" + deliveryToken="${{ secrets.DELIVERY_TOKEN }}" + environment="${{ secrets.ENVIRONMENT }}" + contentType="${{ secrets.CONTENT_TYPE }}" + assetUid="${{ secrets.ASSET_UID }}" + EOF - name: Gradle build and clean run: | ./gradlew clean build From 9dfe45a072b35dd8724e070566ebddd175ea0a6d Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 13 Feb 2024 15:21:16 +0530 Subject: [PATCH 34/43] v3.14.0: function support added - initial sequential sync - sequential sync --- contentstack/build.gradle | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 761cb08b..9cbd3d8f 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" @@ -40,23 +40,7 @@ mavenPublishing { } } -//tasks.register('jacocoTestReport', JacocoReport) { -// dependsOn['testDebugUnitTest', 'createDebugCoverageReport'] -// reports { -// html.enabled = true -// } -// afterEvaluate { -// classDirectories.setFrom(files(classDirectories.files.collect { -// fileTree(dir: it, exclude: '**com/contentstack/okhttp**') -// fileTree(dir: it, exclude: '**com/contentstack/okio**') -// fileTree(dir: it, exclude: '**com/contentstack/txtmark**') -// })) -// } -//} - - android { - //namespace "com.contentstack.sdk" packagingOptions { exclude("META-INF/DEPENDENCIES") exclude("META-INF/LICENSE") @@ -94,7 +78,6 @@ android { } compileSdk 30 defaultConfig { - // Required when setting minSdkVersion to 20 or lower multiDexEnabled true minSdkVersion 23 versionCode 1 @@ -112,7 +95,6 @@ android { debuggable true testCoverageEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - buildConfigField "String", "host", localProperties['host'] buildConfigField "String", "APIKey", localProperties['APIKey'] buildConfigField "String", "deliveryToken", localProperties['deliveryToken'] From e2a1ad7c599ccca87f52bce3047eab987c0025d8 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 13 Feb 2024 15:21:58 +0530 Subject: [PATCH 35/43] v3.14.0: function support added - initial sequential sync - sequential sync --- contentstack/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 9cbd3d8f..396cbf68 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -4,7 +4,6 @@ plugins { } import com.vanniktech.maven.publish.SonatypeHost - android.buildFeatures.buildConfig true mavenPublishing { From 39762c346c63b48801f93753dd3cd762768976b7 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 14 Feb 2024 17:11:50 +0530 Subject: [PATCH 36/43] v3.14.0: function support added - initial sequential sync - sequential sync --- .../main/java/com/contentstack/sdk/Stack.java | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index e57c5a5f..06e3e1a0 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 { @@ -349,9 +349,9 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap * The response also contains a sync token, which you need to store, * since this token is used to get subsequent delta updates later. *
-     *                     

Example :
- * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); - *
+ *

Example :
+ * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); + * * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ @@ -405,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) { @@ -463,9 +463,10 @@ public void seqSync(String seqId, SyncResultCallBack syncCallBack) { * *

Example :
*
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stack.syncFromDate(start_date, new SyncResultCallBack()) { }
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
+ * stack.syncFromDate(start_date, new SyncResultCallBack()) { } + * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ + @Deprecated public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { String startFromDate = convertUTCToISO(fromDate); try { @@ -486,7 +487,9 @@ public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { * To do this, use syncContentType and specify the content type uid as its value. * However, if you do this, the subsequent syncs will only include the entries of the specified content_type. *

+ * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ + @Deprecated public void syncContentType(String contentType, SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); @@ -535,7 +538,9 @@ public void syncLocale(Language language, SyncResultCallBack syncCallBack) { * 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 #seqSync(String, SyncResultCallBack)} instead. */ + @Deprecated public void syncLocale(String localeCode, SyncResultCallBack syncCallBack) { if (localeCode == null) { Objects.requireNonNull("Locale code can not be null"); @@ -563,10 +568,11 @@ public void syncLocale(String localeCode, SyncResultCallBack syncCallBack) { * * stackInstance.syncPublishType(Stack.PublishType.ENTRY_PUBLISHED, new SyncResultCallBack()) { } * - * * + * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ + @Deprecated public void syncPublishType(PublishType type, SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); @@ -609,6 +615,15 @@ public void sync(String contentType, Date fromDate, Language language, PublishTy sync(contentType, fromDate, locale, type, syncCallBack); } + /** + * @param contentType the contentType of which you want to get content + * @param fromDate the date + * @param locale the locale + * @param type PublishType of the content like, entry_published, asset_published + * @param syncCallBack the sync Callback + * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. + */ + @Deprecated public void sync(String contentType, Date fromDate, String locale, PublishType type, SyncResultCallBack syncCallBack) { String startFromDate = convertUTCToISO(fromDate); try { @@ -654,9 +669,14 @@ private void requestSync(final SyncResultCallBack callback) { public void onCompletion(SyncStack syncStack, Error error) { if (error == null) { String paginationToken = syncStack.getPaginationToken(); + String seqToken = syncStack.getSequentialToken(); + if (paginationToken != null) { syncPaginationToken(paginationToken, callback); } + if (seqToken != null && syncStack.getCount() > 0) { + seqSync(seqToken, callback); + } } callback.onCompletion(syncStack, error); } From daaf8a189922eb4c555cde4a7f9d67e11d5a144f Mon Sep 17 00:00:00 2001 From: harshithad0703 Date: Mon, 6 May 2024 16:20:56 +0530 Subject: [PATCH 37/43] feat: gcp support implementation --- .gitignore | 3 + contentstack/build.gradle | 26 +++- .../com/contentstack/sdk/AssetTestCase.java | 13 ++ .../java/com/contentstack/sdk/Config.java | 3 +- .../main/java/com/contentstack/sdk/Stack.java | 111 ++++-------------- 5 files changed, 66 insertions(+), 90 deletions(-) diff --git a/.gitignore b/.gitignore index 968028b6..66adfeb1 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ lib/ src/androidTest/java/com/builtio/contentstack/ApplicationTest.java src/main/res/ contentstack/src/androidTest/java/com/contentstack/sdk/SyncTestCase.java + +# key file +key.keystore \ No newline at end of file diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 396cbf68..06aa4346 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -4,12 +4,13 @@ plugins { } import com.vanniktech.maven.publish.SonatypeHost + android.buildFeatures.buildConfig true mavenPublishing { publishToMavenCentral(SonatypeHost.DEFAULT) signAllPublications() - coordinates("com.contentstack.sdk", "android", "3.14.0") + coordinates("com.contentstack.sdk", "android", "3.13.0") pom { name = "contentstack-android" @@ -39,7 +40,23 @@ mavenPublishing { } } + +tasks.register('jacocoTestReport', JacocoReport) { + dependsOn['testDebugUnitTest', 'createDebugCoverageReport'] + reports { + html.enabled = true + } + afterEvaluate { + classDirectories.setFrom(files(classDirectories.files.collect { + fileTree(dir: it, exclude: '**com/contentstack/okhttp**') + fileTree(dir: it, exclude: '**com/contentstack/okio**') + fileTree(dir: it, exclude: '**com/contentstack/txtmark**') + })) + } +} + android { + //namespace "com.contentstack.sdk" packagingOptions { exclude("META-INF/DEPENDENCIES") exclude("META-INF/LICENSE") @@ -52,12 +69,10 @@ android { exclude("META-INF/*.kotlin_module") } - testOptions { unitTests.all { jacoco { includeNoLocationClasses = true - excludes = ['jdk.internal.*'] } } } @@ -77,6 +92,7 @@ android { } compileSdk 30 defaultConfig { + // Required when setting minSdkVersion to 20 or lower multiDexEnabled true minSdkVersion 23 versionCode 1 @@ -94,6 +110,7 @@ android { debuggable true testCoverageEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + buildConfigField "String", "host", localProperties['host'] buildConfigField "String", "APIKey", localProperties['APIKey'] buildConfigField "String", "deliveryToken", localProperties['deliveryToken'] @@ -115,12 +132,14 @@ 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' @@ -139,5 +158,6 @@ 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/androidTest/java/com/contentstack/sdk/AssetTestCase.java b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java index 5cca358e..7137b885 100644 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java @@ -178,4 +178,17 @@ public void test_AZURE_NA() throws Exception { stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); } + @Test + public void test_GCP_NA() throws Exception { + Config config = new Config(); + String DEFAULT_API_KEY = BuildConfig.APIKey; + String DEFAULT_DELIVERY_TOKEN = BuildConfig.deliveryToken; + String DEFAULT_ENV = BuildConfig.environment; + String DEFAULT_HOST = BuildConfig.host; + config.setHost(DEFAULT_HOST); + config.setRegion(Config.ContentstackRegion.GCP_NA); + Context appContext = InstrumentationRegistry.getTargetContext(); + stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); + } + } diff --git a/contentstack/src/main/java/com/contentstack/sdk/Config.java b/contentstack/src/main/java/com/contentstack/sdk/Config.java index 7d188ece..4391548a 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Config.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Config.java @@ -52,6 +52,7 @@ public void setBranch(String branch) { * config.setRegion(ContentstackRegion.EU); * config.setRegion(ContentstackRegion.AZURE_EU); * config.setRegion(ContentstackRegion.AZURE_NA); + * config.setRegion(ContentstackRegion.GCP_NA); * } * */ @@ -77,7 +78,7 @@ public Config earlyAccess(String[] earlyAccess) { return this; } - public enum ContentstackRegion {US, EU, AZURE_NA, AZURE_EU} + public enum ContentstackRegion {US, EU, AZURE_NA, AZURE_EU, GCP_NA} /** * Config constructor diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index 06e3e1a0..d5bcb87b 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 ishaileshmishra. + * Created by Shailesh Mishra. * 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,14 +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 :
*
-     *                                                                                 

Example :
- * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); - *
- * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. + * + * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); + * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} + * */ - @Deprecated public void sync(SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); @@ -383,9 +384,7 @@ public void sync(SyncResultCallBack syncCallBack) { * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} * * - * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ - @Deprecated public void syncPaginationToken(String paginationToken, SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); @@ -405,9 +404,8 @@ 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(); @@ -418,42 +416,6 @@ 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. @@ -463,10 +425,9 @@ public void seqSync(String seqId, SyncResultCallBack syncCallBack) { * *

Example :
*
-     *                                                              stack.syncFromDate(start_date, new SyncResultCallBack()) { }
-     *                                          @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)}  instead.
+     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            stack.syncFromDate(start_date, new SyncResultCallBack()) { }
+     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
*/ - @Deprecated public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { String startFromDate = convertUTCToISO(fromDate); try { @@ -487,9 +448,7 @@ public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { * To do this, use syncContentType and specify the content type uid as its value. * However, if you do this, the subsequent syncs will only include the entries of the specified content_type. *

- * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ - @Deprecated public void syncContentType(String contentType, SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); @@ -516,9 +475,7 @@ 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 { @@ -538,12 +495,10 @@ public void syncLocale(Language language, SyncResultCallBack syncCallBack) { * 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 #seqSync(String, SyncResultCallBack)} instead. */ - @Deprecated public void syncLocale(String localeCode, SyncResultCallBack syncCallBack) { - if (localeCode == null) { - Objects.requireNonNull("Locale code can not be null"); + if (localeCode==null){ + Objects.requireNonNull("localeCode can not be null"); } try { this.syncParams = new JSONObject(); @@ -568,11 +523,10 @@ public void syncLocale(String localeCode, SyncResultCallBack syncCallBack) { * * stackInstance.syncPublishType(Stack.PublishType.ENTRY_PUBLISHED, new SyncResultCallBack()) { } * + * * - * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. */ - @Deprecated public void syncPublishType(PublishType type, SyncResultCallBack syncCallBack) { try { this.syncParams = new JSONObject(); @@ -609,21 +563,11 @@ 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); } - /** - * @param contentType the contentType of which you want to get content - * @param fromDate the date - * @param locale the locale - * @param type PublishType of the content like, entry_published, asset_published - * @param syncCallBack the sync Callback - * @deprecated This method is deprecated. Use {@link #seqSync(String, SyncResultCallBack)} instead. - */ - @Deprecated public void sync(String contentType, Date fromDate, String locale, PublishType type, SyncResultCallBack syncCallBack) { String startFromDate = convertUTCToISO(fromDate); try { @@ -669,14 +613,9 @@ private void requestSync(final SyncResultCallBack callback) { public void onCompletion(SyncStack syncStack, Error error) { if (error == null) { String paginationToken = syncStack.getPaginationToken(); - String seqToken = syncStack.getSequentialToken(); - if (paginationToken != null) { syncPaginationToken(paginationToken, callback); } - if (seqToken != null && syncStack.getCount() > 0) { - seqSync(seqToken, callback); - } } callback.onCompletion(syncStack, error); } From df0f6f29f67900db2f544bc4ef7f015252e329e3 Mon Sep 17 00:00:00 2001 From: harshithad0703 Date: Mon, 6 May 2024 16:39:13 +0530 Subject: [PATCH 38/43] updated path for keystore --- contentstack/build.gradle | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 06aa4346..3b20dcca 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -71,20 +71,20 @@ android { testOptions { unitTests.all { - jacoco { - includeNoLocationClasses = true - } + // jacoco { + // includeNoLocationClasses = true + // } } } signingConfigs { debug { - storeFile file("/Users/shaileshmishra/keystore/key.keystore") + storeFile file("../key.keystore") storePassword 'android' keyAlias 'key0' keyPassword 'android' } release { - storeFile file("/Users/shaileshmishra/keystore/key.keystore") + storeFile file("../key.keystore") storePassword 'android' keyAlias 'key0' keyPassword 'android' @@ -98,7 +98,7 @@ android { versionCode 1 versionName "1.0" useLibrary 'org.apache.http.legacy' - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' signingConfig signingConfigs.release } @@ -143,7 +143,7 @@ dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test:core:1.5.0' - androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', { + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { exclude group: 'com.android.support', module: 'support-annotations' }) } From f1dab8f2a85a0a7d0b2be72da7b73c67cbc0b89a Mon Sep 17 00:00:00 2001 From: harshithad0703 Date: Tue, 7 May 2024 17:17:43 +0530 Subject: [PATCH 39/43] chore: version bump to 3.14.0 --- .gitignore | 2 +- contentstack/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 66adfeb1..24d917a9 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,4 @@ src/main/res/ contentstack/src/androidTest/java/com/contentstack/sdk/SyncTestCase.java # key file -key.keystore \ No newline at end of file +# key.keystore \ No newline at end of file diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 3b20dcca..c7540b6e 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" From 0158902f4f4acab2e6498eb3bfc0e57e5ffe67ab Mon Sep 17 00:00:00 2001 From: harshithad0703 Date: Tue, 7 May 2024 17:26:33 +0530 Subject: [PATCH 40/43] changeLog updated --- .gitignore | 2 +- CHANGELOG.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 24d917a9..66adfeb1 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,4 @@ src/main/res/ contentstack/src/androidTest/java/com/contentstack/sdk/SyncTestCase.java # key file -# key.keystore \ No newline at end of file +key.keystore \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bf7bb4a7..09870501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,12 @@ ## Version 3.14.0 -### Date: 10-Feb-2024 +### Date: 13-May-2024 - support of new sync api - initSeqSync in stack class - seqSync in stack class +- GCP support implementation --- From 8f9b157466ad9d486980bce7b37727671af6ffd9 Mon Sep 17 00:00:00 2001 From: harshithad0703 Date: Tue, 7 May 2024 18:39:11 +0530 Subject: [PATCH 41/43] feat: specified host name in stack.java --- contentstack/src/main/java/com/contentstack/sdk/Stack.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index d5bcb87b..4c78cdd4 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -80,6 +80,8 @@ protected void setConfig(Config config) { URL = "azure-na-cdn.contentstack.com"; } else if (region.equalsIgnoreCase("azure_eu")) { URL = "azure-eu-cdn.contentstack.com"; + }else if (region.equalsIgnoreCase("gcp_na")) { + URL = "gcp-na-cdn.contentstack.com"; } else { URL = region + "-" + URL; } From e1c067ffa2d67623b7c2f9765cb7690c7c3c38da Mon Sep 17 00:00:00 2001 From: Vikram Kalta Date: Wed, 8 May 2024 22:45:43 +0100 Subject: [PATCH 42/43] feat: added support to convert json to html --- contentstack/build.gradle | 24 +- .../com/contentstack/sdk/DefaultOption.java | 216 ++++++++++++++++++ .../java/com/contentstack/sdk/Metadata.java | 104 +++++++++ .../java/com/contentstack/sdk/NodeToHTML.java | 45 ++++ .../java/com/contentstack/sdk/Option.java | 24 ++ .../java/com/contentstack/sdk/SDKUtil.java | 195 ++++++++++++++++ 6 files changed, 601 insertions(+), 7 deletions(-) create mode 100644 contentstack/src/main/java/com/contentstack/sdk/DefaultOption.java create mode 100644 contentstack/src/main/java/com/contentstack/sdk/Metadata.java create mode 100644 contentstack/src/main/java/com/contentstack/sdk/NodeToHTML.java create mode 100644 contentstack/src/main/java/com/contentstack/sdk/Option.java diff --git a/contentstack/build.gradle b/contentstack/build.gradle index c7540b6e..8bd336a5 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.15.0") pom { name = "contentstack-android" @@ -76,6 +76,11 @@ android { // } } } + // signing { + // // Specify key and other signing details + // useGpgCmd() + // sign configurations.archives + // } signingConfigs { debug { storeFile file("../key.keystore") @@ -98,8 +103,13 @@ android { versionCode 1 versionName "1.0" useLibrary 'org.apache.http.legacy' +<<<<<<< Updated upstream testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' signingConfig signingConfigs.release +======= + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + signingConfig signingConfigs.release +>>>>>>> Stashed changes } @@ -111,12 +121,12 @@ android { testCoverageEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - buildConfigField "String", "host", localProperties['host'] - buildConfigField "String", "APIKey", localProperties['APIKey'] - buildConfigField "String", "deliveryToken", localProperties['deliveryToken'] - buildConfigField "String", "environment", localProperties['environment'] - buildConfigField "String", "contentTypeUID", localProperties['contentType'] - buildConfigField "String", "assetUID", localProperties['assetUid'] + buildConfigField "String", "host", localProperties['host'] + buildConfigField "String", "APIKey", localProperties['APIKey'] + buildConfigField "String", "deliveryToken", localProperties['deliveryToken'] + buildConfigField "String", "environment", localProperties['environment'] + buildConfigField "String", "contentTypeUID", localProperties['contentType'] + buildConfigField "String", "assetUID", localProperties['assetUid'] } release { minifyEnabled false diff --git a/contentstack/src/main/java/com/contentstack/sdk/DefaultOption.java b/contentstack/src/main/java/com/contentstack/sdk/DefaultOption.java new file mode 100644 index 00000000..39eff7d8 --- /dev/null +++ b/contentstack/src/main/java/com/contentstack/sdk/DefaultOption.java @@ -0,0 +1,216 @@ +package com.contentstack.sdk; + +import android.text.TextUtils; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Objects; + +public class DefaultOption implements Option { + @Override + public String renderOptions(JSONObject embeddedObject, Metadata metadata) { + switch (metadata.getStyleType()) { + case BLOCK: + return "

" + findTitleOrUid(embeddedObject) + "

Content type: " + embeddedObject.optString("_content_type_uid") + "

"; + case INLINE: + return "" + findTitleOrUid(embeddedObject) + ""; + case LINK: + return "" + findTitleOrUid(embeddedObject) + ""; + case DISPLAY: + return "\"""; + default: + return ""; + } + } + + @Override + public String renderMark(MarkType markType, String text) { + switch (markType) { + case SUPERSCRIPT: + return "" + text + ""; + case SUBSCRIPT: + return "" + text + ""; + case INLINECODE: + return "" + text + ""; + case STRIKETHROUGH: + return "" + text + ""; + case UNDERLINE: + return "" + text + ""; + case ITALIC: + return "" + text + ""; + case BOLD: + return "" + text + ""; + case BREAK: + return "
" + text.replace("\n", ""); + default: + return text; + } + } + + private String escapeInjectHtml(JSONObject nodeObj, String nodeType) { + String injectedHtml = getNodeStr(nodeObj, nodeType); + return TextUtils.htmlEncode(injectedHtml); + } + + @Override + public String renderNode(String nodeType, JSONObject nodeObject, NodeCallback callback) { + String strAttrs = strAttrs(nodeObject); + String children = callback.renderChildren(nodeObject.optJSONArray("children")); + switch (nodeType) { + case "p": + return "" + children + "

"; + case "a": + return "" + children + ""; + case "img": + String assetLink = getNodeStr(nodeObject, "asset-link"); + if (!assetLink.isEmpty()) { + JSONObject attrs = nodeObject.optJSONObject("attrs"); + if (attrs.has("link")) { + return "" + "" + children + ""; + } + return "" + children; + } + return "" + children; + case "embed": + return ""; + case "h1": + return "" + children + ""; + case "h2": + return "" + children + ""; + case "h3": + return "" + children + ""; + case "h4": + return "" + children + ""; + case "h5": + return "" + children + ""; + case "h6": + return "" + children + ""; + case "ol": + return "" + children + ""; + case "ul": + return "" + children + ""; + case "li": + return "" + children + ""; + case "hr": + return ""; + case "table": + return "" + children + "
"; + case "thead": + return "" + children + ""; + case "tbody": + return "" + children + ""; + case "tfoot": + return "" + children + ""; + case "tr": + return "" + children + ""; + case "th": + return "" + children + ""; + case "td": + return "" + children + ""; + case "blockquote": + return "" + children + ""; + case "code": + return "" + children + ""; + case "reference": + return ""; + case "fragment": + return "" + children + ""; + default: + return children; + } + } + + String strAttrs(JSONObject nodeObject) { + StringBuilder result = new StringBuilder(); + if (nodeObject.has("attrs")) { + JSONObject attrsObject = nodeObject.optJSONObject("attrs"); + if (attrsObject != null && attrsObject.length() > 0) { + for (Iterator it = attrsObject.keys(); it.hasNext(); ) { + String key = it.next(); + Object objValue = attrsObject.opt(key); + String value = objValue.toString(); + // If style is available, do styling calculations + if (Objects.equals(key, "style")) { + String resultStyle = stringifyStyles(attrsObject.optJSONObject("style")); + result.append(" ").append(key).append("=\"").append(resultStyle).append("\""); + } else { + String[] ignoreKeys = {"href", "asset-link", "src", "url"}; + ArrayList ignoreKeysList = new ArrayList<>(Arrays.asList(ignoreKeys)); + if (!ignoreKeysList.contains(key)) { + result.append(" ").append(key).append("=\"").append(value).append("\""); + } + } + } + } + } + return result.toString(); + } + + private String stringifyStyles(JSONObject style) { + Map styleMap = new HashMap<>(); + + // Convert JSONObject to a Map + Iterator keys = style.keys(); + while (keys.hasNext()) { + String key = keys.next(); + String value = null; + try { + value = style.getString(key); + } catch (JSONException e) { + throw new RuntimeException(e); + } + styleMap.put(key, value); + } + + StringBuilder styleString = new StringBuilder(); + + for (Map.Entry entry : styleMap.entrySet()) { + String property = entry.getKey(); + String value = entry.getValue(); + + styleString.append(property).append(": ").append(value).append("; "); + } + + return styleString.toString(); + } + + private String getNodeStr(JSONObject nodeObject, String key) { + String herf = nodeObject.optJSONObject("attrs").optString(key); // key might be [href/src] + if (herf == null || herf.isEmpty()) { + herf = nodeObject.optJSONObject("attrs").optString("url"); + } + return herf; + } + + protected String findTitleOrUid(JSONObject embeddedObject) { + String _title = ""; + if (embeddedObject != null) { + if (embeddedObject.has("title") && !embeddedObject.optString("title").isEmpty()) { + _title = embeddedObject.optString("title"); + } else if (embeddedObject.has("uid")) { + _title = embeddedObject.optString("uid"); + } + } + return _title; + } + + protected String findAssetTitle(JSONObject embeddedObject) { + String _title = ""; + if (embeddedObject != null) { + if (embeddedObject.has("title") && !embeddedObject.optString("title").isEmpty()) { + _title = embeddedObject.optString("title"); + } else if (embeddedObject.has("filename")) { + _title = embeddedObject.optString("filename"); + } else if (embeddedObject.has("uid")) { + _title = embeddedObject.optString("uid"); + } + } + return _title; + } +} diff --git a/contentstack/src/main/java/com/contentstack/sdk/Metadata.java b/contentstack/src/main/java/com/contentstack/sdk/Metadata.java new file mode 100644 index 00000000..aac18643 --- /dev/null +++ b/contentstack/src/main/java/com/contentstack/sdk/Metadata.java @@ -0,0 +1,104 @@ +package com.contentstack.sdk; + +import java.util.jar.Attributes; + +public class Metadata { + String text; + String itemType; + String itemUid; + String contentTypeUid; + StyleType styleType; + String outerHTML; + Attributes attributes; + + public Metadata(String text, String itemType, String itemUid, String contentTypeUid, + String styleType, String outerHTML, Attributes attributes) { + this.text = text; + this.itemType = itemType; + this.itemUid = itemUid; + this.contentTypeUid = contentTypeUid; + this.styleType = StyleType.valueOf(styleType.toUpperCase()); + this.outerHTML = outerHTML; + this.attributes = attributes; + } + + @Override + public String toString() { + return "EmbeddedObject{" + + "text='" + text + '\'' + + "type='" + itemType + '\'' + + ", uid='" + itemUid + '\'' + + ", contentTypeUid='" + contentTypeUid + '\'' + + ", sysStyleType=" + styleType + + ", outerHTML='" + outerHTML + '\'' + + ", attributes='" + attributes + '\'' + + '}'; + } + + /** + * The getText() function returns the value of the text variable. + * + * @return The method is returning a String value. + */ + public String getText() { + return text; + } + + /** + * The getItemType() function returns the type of an item. + * + * @return The method is returning the value of the variable "itemType". + */ + public String getItemType() { + return itemType; + } + + /** + * The function returns the attributes of an object. + * + * @return The method is returning an object of type Attributes. + */ + public Attributes getAttributes() { + return attributes; + } + + /** + * The getItemUid() function returns the itemUid value. + * + * @return The method is returning the value of the variable "itemUid". + */ + public String getItemUid() { + return itemUid; + } + + /** + * The function returns the content type UID as a string. + * + * @return The method is returning the value of the variable "contentTypeUid". + */ + public String getContentTypeUid() { + return contentTypeUid; + } + + /** + * The function returns the value of the styleType variable. + * + * @return The method is returning the value of the variable "styleType" of type StyleType. + */ + public StyleType getStyleType() { + return styleType; + } + + /** + * The getOuterHTML() function returns the outer HTML of an element. + * + * @return The method is returning the value of the variable "outerHTML". + */ + public String getOuterHTML() { + return outerHTML; + } +} + +enum StyleType { + BLOCK, INLINE, LINK, DISPLAY, DOWNLOAD, +} \ No newline at end of file diff --git a/contentstack/src/main/java/com/contentstack/sdk/NodeToHTML.java b/contentstack/src/main/java/com/contentstack/sdk/NodeToHTML.java new file mode 100644 index 00000000..e290582a --- /dev/null +++ b/contentstack/src/main/java/com/contentstack/sdk/NodeToHTML.java @@ -0,0 +1,45 @@ +package com.contentstack.sdk; + +import org.json.JSONObject; + +public class NodeToHTML { + private NodeToHTML() { + throw new IllegalStateException("Could not create instance of NodeToHTML"); + } + public static String textNodeToHTML(JSONObject nodeText, Option renderOption) { + String text = nodeText.optString("text"); + text = text.replace("\n", "
"); + if (nodeText.has("superscript")) { + text = renderOption.renderMark(MarkType.SUPERSCRIPT, text); + } + if (nodeText.has("subscript")) { + text = renderOption.renderMark(MarkType.SUBSCRIPT, text); + } + if (nodeText.has("inlineCode")) { + text = renderOption.renderMark(MarkType.INLINECODE, text); + } + if (nodeText.has("strikethrough")) { + text = renderOption.renderMark(MarkType.STRIKETHROUGH, text); + } + if (nodeText.has("underline")) { + text = renderOption.renderMark(MarkType.UNDERLINE, text); + } + if (nodeText.has("italic")) { + text = renderOption.renderMark(MarkType.ITALIC, text); + } + if (nodeText.has("bold")) { + text = renderOption.renderMark(MarkType.BOLD, text); + } + if (nodeText.has("break")) { + if (!text.contains("
")) { + text = renderOption.renderMark(MarkType.BREAK, text); + } + // text = renderOption.renderMark(MarkType.BREAK, text); + } + return text; + } +} + +enum MarkType { + BOLD, ITALIC, UNDERLINE, STRIKETHROUGH, INLINECODE, SUBSCRIPT, SUPERSCRIPT, BREAK, +} diff --git a/contentstack/src/main/java/com/contentstack/sdk/Option.java b/contentstack/src/main/java/com/contentstack/sdk/Option.java new file mode 100644 index 00000000..c218597f --- /dev/null +++ b/contentstack/src/main/java/com/contentstack/sdk/Option.java @@ -0,0 +1,24 @@ +package com.contentstack.sdk; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +public interface Option { + String renderOptions(JSONObject embeddedObject, Metadata metadata); + String renderMark(MarkType markType, String renderText); + String renderNode(String nodeType, JSONObject nodeObject, NodeCallback callback); +} + +interface NodeCallback { + + /** + * The function takes a JSONArray of nodes and returns a string representation of their children. + * + * @param nodeJsonArray The `nodeJsonArray` parameter is a JSONArray object that contains a + * collection of JSON objects representing nodes. Each JSON object represents a node and contains + * information about the node's properties and children. + * @return The method is returning a String. + */ + String renderChildren(JSONArray nodeJsonArray); +} \ No newline at end of file diff --git a/contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java b/contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java index 460b41a8..acf0723a 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java +++ b/contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java @@ -8,7 +8,10 @@ import android.os.SystemClock; import android.util.Log; +import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; +import org.w3c.dom.Attr; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; @@ -19,9 +22,15 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Calendar; import java.util.Date; +import java.util.List; +import java.util.Optional; +import java.util.Set; import java.util.TimeZone; +import java.util.jar.Attributes; +import java.util.stream.StreamSupport; /** * @author contentstack.com @@ -246,4 +255,190 @@ public static Calendar parseDate(String date, String dateFormat, TimeZone timeZo return cal; } + public static void jsonToHTML(JSONArray entryArray, String[] keyPath, Option option) throws JSONException { + for (int i = 0; i < entryArray.length(); i++) { + Object jsonObj = entryArray.get(i); + jsonToHTML((JSONObject) jsonObj, keyPath, option); + } + } + + public static void jsonToHTML(JSONObject entry, String[] keyPath, Option renderOption) throws JSONException { + MetaToEmbedCallback converter = metadata -> { + boolean available = entry.has("_embedded_items"); + if (available) { + JSONObject jsonArray = entry.optJSONObject("_embedded_items"); + return findEmbeddedItems(jsonArray, metadata); + } + return Optional.empty(); + }; + ContentCallback callback = content -> { + if (content instanceof JSONArray) { + JSONArray contentArray = (JSONArray) content; + return enumerateContents(contentArray, renderOption, converter); + } else if (content instanceof JSONObject) { + JSONObject jsonObject = (JSONObject) content; + return enumerateContent(jsonObject, renderOption, converter); + } + return null; + }; + for (String path: keyPath) { + findContent(entry, path, callback); + } + } + + private static void findContent(JSONObject entryObj, String path, ContentCallback contentCallback) throws JSONException { + String[] arrayString = path.split("\\."); + getContent(arrayString, entryObj, contentCallback); + } + + private static void getContent(String[] arrayString, JSONObject entryObj, ContentCallback contentCallback) throws JSONException { + if (arrayString != null && arrayString.length != 0) { + String path = arrayString[0]; + if (arrayString.length == 1) { + Object varContent = entryObj.opt(path); + if (varContent instanceof String || varContent instanceof JSONArray || varContent instanceof JSONObject) { + entryObj.put(path, contentCallback.contentObject(varContent)); + } + } else { + List list = new ArrayList<>(Arrays.asList(arrayString)); + list.remove(path); + String[] newArrayString = list.toArray(new String[0]); + if (entryObj.opt(path) instanceof JSONObject) { + getContent(newArrayString, entryObj.optJSONObject(path), contentCallback); + } else if (entryObj.opt(path) instanceof JSONArray) { + JSONArray jsonArray = entryObj.optJSONArray(path); + for (int idx = 0; idx < jsonArray.length(); idx++) { + getContent(newArrayString, jsonArray.optJSONObject(idx), contentCallback); + } + } + } + } + } + + private static Optional findEmbeddedItems(JSONObject jsonObject, Metadata metadata) { + Set allKeys = (Set) jsonObject.keys(); + for (String key: allKeys) { + JSONArray jsonArray = jsonObject.optJSONArray(key); + + Optional filteredContent = Optional.empty(); + for (int i = 0; i < jsonArray.length(); i++) { + try { + JSONObject obj = jsonArray.getJSONObject(i); + if (jsonObject.optString("uid").equalsIgnoreCase(metadata.getItemUid())) { + filteredContent = Optional.of(obj); + break; + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + if (filteredContent.isPresent()) { + return filteredContent; + } + } + return Optional.empty(); + } + + private static Object enumerateContents(JSONArray contentArray, Option renderObject, MetaToEmbedCallback item) { + JSONArray jsonArrayRTEContent = new JSONArray(); + for (int i = 0; i < contentArray.length(); i++) { + Object RTE = null; + try { + RTE = contentArray.get(i); + } catch (JSONException e) { + throw new RuntimeException(e); + } + JSONObject jsonObject = (JSONObject) RTE; + String renderContent = enumerateContent(jsonObject, renderObject, item); + jsonArrayRTEContent.put(renderContent); + } + return jsonArrayRTEContent; + } + private static String enumerateContent(JSONObject jsonObject, Option renderObject, MetaToEmbedCallback item) { + if (jsonObject.length() > 0 && jsonObject.has("type") && jsonObject.has("children")) { + if (jsonObject.opt("type").equals("doc")) { + return doRawProcessing(jsonObject.optJSONArray("children"), renderObject, item); + } + } + return ""; + } + private static String doRawProcessing(JSONArray children, Option renderObject, MetaToEmbedCallback embedItem) { + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < children.length(); i++) { + Object item = null; + try { + item = children.get(i); + } catch (JSONException e) { + throw new RuntimeException(e); + } + JSONObject child; + if (item instanceof JSONObject) { + child = (JSONObject) item; + stringBuilder.append(extractKeys(child, renderObject, embedItem)); + } + } + return stringBuilder.toString(); + } + + private static final String ASSET = "asset"; + private static String extractKeys(JSONObject jsonNode, Option renderObject, MetaToEmbedCallback embedItem) { + if (!jsonNode.has("type") && jsonNode.has("text")) { + return NodeToHTML.textNodeToHTML(jsonNode, renderObject); + } else if (jsonNode.has("type")) { + String nodeType = jsonNode.optString("type"); + if (nodeType.equalsIgnoreCase("reference")) { + JSONObject attrObj = jsonNode.optJSONObject("attrs"); + String attrType = attrObj.optString("type"); + Metadata metadata; + + if (attrType.equalsIgnoreCase(ASSET)) { + String text = attrObj.optString("text"); + String uid = attrObj.optString("asset-uid"); + String style = attrObj.optString("display-type"); + metadata = new Metadata(text, attrType, uid, ASSET, style, "", new Attributes()); + } else { + String text = attrObj.optString("text"); + String uid = attrObj.optString("entry-uid"); + String contentType = attrObj.optString("content-type-uid"); + String style = attrObj.optString("display-type"); + metadata = new Metadata(text, attrType, uid, contentType, style, "", new Attributes()); + } + Optional filteredContent = embedItem.toEmbed(metadata); + if (filteredContent.isPresent()) { + JSONObject contentToPass = filteredContent.get(); + return getStringOption(renderObject, metadata, contentToPass); + } else { + if (attrType.equalsIgnoreCase(ASSET)) { + return renderObject.renderNode("img", jsonNode, nodeJsonArray -> doRawProcessing(nodeJsonArray, renderObject, embedItem)); + } + } + } else { + return renderObject.renderNode(nodeType, jsonNode, nodeJsonArray -> doRawProcessing(nodeJsonArray, renderObject, embedItem)); + } + } + return ""; + } + private static String getStringOption(Option option, Metadata metadata, JSONObject contentToPass) { + String stringOption = option.renderOptions(contentToPass, metadata); + if (stringOption == null) { + DefaultOption defaultOptions = new DefaultOption(); + stringOption = defaultOptions.renderOptions(contentToPass, metadata); + } + return stringOption; + } } + +interface MetaToEmbedCallback { + Optional toEmbed(Metadata metadata); +} +interface ContentCallback { + + /** + * The function contentObject takes an object as input and returns an object as output. + * + * @param content The content parameter is an object that represents the content to be passed to + * the contentObject function. + * @return The contentObject is being returned. + */ + Object contentObject(Object content); +} \ No newline at end of file From ed9a522bbbe1d9e3faa0cee5e5663b01d9827373 Mon Sep 17 00:00:00 2001 From: Vikram Kalta Date: Wed, 15 May 2024 22:10:07 +0100 Subject: [PATCH 43/43] fix: resolved conflicts --- contentstack/build.gradle | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 8bd336a5..e99ba6b8 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -103,13 +103,8 @@ android { versionCode 1 versionName "1.0" useLibrary 'org.apache.http.legacy' -<<<<<<< Updated upstream testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' signingConfig signingConfigs.release -======= - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - signingConfig signingConfigs.release ->>>>>>> Stashed changes }