diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 7f77e123..8f281843 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -34,4 +34,4 @@ jobs: 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_signingInMemoryKeyPassword: ${{ secrets.signingInMemoryKeyPassword }} \ No newline at end of file diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 974b390c..b43da5ae 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -2,6 +2,8 @@ name: Publish - Snapshot on: push: + branches: + - master jobs: publish: @@ -41,4 +43,4 @@ jobs: 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_signingInMemoryKeyPassword: ${{ secrets.signingInMemoryKeyPassword }} \ No newline at end of file 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/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 --- diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 396cbf68..c7540b6e 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -4,6 +4,7 @@ plugins { } import com.vanniktech.maven.publish.SonatypeHost + android.buildFeatures.buildConfig true mavenPublishing { @@ -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,24 +69,22 @@ android { exclude("META-INF/*.kotlin_module") } - testOptions { unitTests.all { - jacoco { - includeNoLocationClasses = true - excludes = ['jdk.internal.*'] - } + // 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' @@ -77,12 +92,13 @@ android { } compileSdk 30 defaultConfig { + // Required when setting minSdkVersion to 20 or lower multiDexEnabled true minSdkVersion 23 versionCode 1 versionName "1.0" useLibrary 'org.apache.http.legacy' - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' signingConfig signingConfigs.release } @@ -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,16 +132,18 @@ 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' - 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' }) } @@ -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..4c78cdd4 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;
@@ -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;
}
@@ -291,17 +293,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 +350,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.
+ *
+ * - *- * @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 +386,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 +406,8 @@ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncC * and the details of the content that was deleted or updated. *
Example :
- * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); - *
- * @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 +418,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 +427,9 @@ public void seqSync(String seqId, SyncResultCallBack syncCallBack) {
*
*
- * 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 +450,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 +477,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 +497,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 +525,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 +565,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 +615,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);
}