From 71edef26e902dbab795e5ad4d0150dcee0e6c0ec Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 26 Apr 2023 20:17:19 +0530 Subject: [PATCH 01/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- build.gradle | 4 +- contentstack/build.gradle | 23 +- ...stCase.java => AssetInstrumentedTest.java} | 37 +- ...stCase.java => EntryInstrumentedTest.java} | 32 +- ...stCase.java => QueryInstrumentedTest.java} | 23 +- .../sdk/SyncInstrumentedTest.java | 238 +++++++++++++ ...se.java => TransformInstrumentedTest.java} | 15 +- contentstack/src/main/AndroidManifest.xml | 29 +- .../main/java/com/contentstack/sdk/Asset.java | 27 +- .../com/contentstack/sdk/AssetLibrary.java | 13 +- .../contentstack/sdk/CSBackgroundTask.java | 12 +- .../contentstack/sdk/CSHttpConnection.java | 6 +- .../java/com/contentstack/sdk/Config.java | 22 +- .../main/java/com/contentstack/sdk/Entry.java | 118 ++++--- .../java/com/contentstack/sdk/EntryModel.java | 16 +- .../sdk/InvalidInputException.java | 32 ++ .../main/java/com/contentstack/sdk/Query.java | 9 + .../main/java/com/contentstack/sdk/Stack.java | 322 +++++++----------- .../com/contentstack/sdk/package-info.java | 5 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 3418 -> 0 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 2206 -> 0 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 4842 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 7718 -> 0 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- scripts/publish-module.gradle | 2 +- talismanrc | 1 + 26 files changed, 587 insertions(+), 401 deletions(-) rename contentstack/src/androidTest/java/com/contentstack/sdk/{AssetTestCase.java => AssetInstrumentedTest.java} (86%) rename contentstack/src/androidTest/java/com/contentstack/sdk/{EntryTestCase.java => EntryInstrumentedTest.java} (94%) rename contentstack/src/androidTest/java/com/contentstack/sdk/{QueryTestCase.java => QueryInstrumentedTest.java} (98%) create mode 100644 contentstack/src/androidTest/java/com/contentstack/sdk/SyncInstrumentedTest.java rename contentstack/src/androidTest/java/com/contentstack/sdk/{TransformTestcase.java => TransformInstrumentedTest.java} (95%) create mode 100644 contentstack/src/main/java/com/contentstack/sdk/InvalidInputException.java create mode 100755 contentstack/src/main/java/com/contentstack/sdk/package-info.java delete mode 100755 contentstack/src/main/res/mipmap-hdpi/ic_launcher.png delete mode 100755 contentstack/src/main/res/mipmap-mdpi/ic_launcher.png delete mode 100755 contentstack/src/main/res/mipmap-xhdpi/ic_launcher.png delete mode 100755 contentstack/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 talismanrc diff --git a/build.gradle b/build.gradle index 0e84797f..389b0532 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,4 @@ buildscript { - ext.jacocoVersion = '0.8.8' repositories { @@ -11,7 +10,6 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.0.4' //4.1.3 classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' - // NOTE: Do not place your application dependencies here classpath "org.jacoco:org.jacoco.core:$jacocoVersion" } } @@ -19,6 +17,6 @@ buildscript { apply plugin: 'io.github.gradle-nexus.publish-plugin' apply from: "${rootDir}/scripts/publish-root.gradle" -task clean(type: Delete) { +tasks.register('clean', Delete) { delete rootProject.buildDir } \ No newline at end of file diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 4077cbf1..281a8a17 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'jacoco' ext { PUBLISH_GROUP_ID = 'com.contentstack.sdk' PUBLISH_ARTIFACT_ID = 'android' - PUBLISH_VERSION = '3.11.0' + PUBLISH_VERSION = '3.12.0-SNAPSHOT' PUBLISH_DESCRIPTION = 'The Content Delivery SDK is used to retrieve content from your Contentstack account and deliver it to your web or mobile properties.' PUBLISH_URL = 'https://github.com/contentstack/contentstack-android' PUBLISH_LICENSE_NAME = 'MIT License' @@ -23,18 +23,21 @@ def localProperties = new Properties() localProperties.load(new FileInputStream(rootProject.file("local.properties"))) android { - compileSdkVersion 33 + namespace 'com.contentstack.sdk' compileSdk 33 - buildToolsVersion '30.0.2' defaultConfig { - minSdkVersion 19 + minSdk 19 + targetSdk 33 versionCode 1 - versionName "1.0.0" + versionName "1.0" + multiDexEnabled true + vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { debug { + minifyEnabled false debuggable true testCoverageEnabled true buildConfigField "String", "host", localProperties['host'] @@ -43,8 +46,8 @@ android { buildConfigField "String", "environment", localProperties['env'] buildConfigField "String", "contentTypeUID", localProperties['contentType'] buildConfigField "String", "assetUID", localProperties['assetUid'] + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } - release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' @@ -74,12 +77,8 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - //testImplementation 'junit:junit:5.9.2' - // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.android.volley:volley:1.2.1' - androidTestImplementation 'androidx.test:core:1.5.0' - androidTestImplementation "androidx.test:runner:1.5.2" - androidTestImplementation "androidx.test:rules:1.5.0" + testImplementation 'junit:junit:5.9.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } \ No newline at end of file diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java similarity index 86% rename from contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java rename to contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java index fb82ca09..105b13ed 100644 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java @@ -6,7 +6,7 @@ import android.content.Context; import android.util.Log; -import androidx.test.core.app.ApplicationProvider; +import androidx.test.platform.app.InstrumentationRegistry; import org.junit.BeforeClass; import org.junit.FixMethodOrder; @@ -15,24 +15,24 @@ import java.util.List; + @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class AssetTestCase { +public class AssetInstrumentedTest { - private final String TAG = AssetTestCase.class.getSimpleName(); private static String assetUid = BuildConfig.assetUID; private static Stack stack; + private final String TAG = AssetInstrumentedTest.class.getSimpleName(); @BeforeClass public static void oneTimeSetUp() throws Exception { - Context context = ApplicationProvider.getApplicationContext(); - + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 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); - stack = Contentstack.stack(context, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); + stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); } @@ -164,17 +164,18 @@ public void onCompletion(ResponseType responseType, Error error) { }); } - @Test - public void test_AZURE_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.AZURE_NA); - Context appContext = ApplicationProvider.getApplicationContext(); - stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); - } + +// @Test +// public void test_AZURE_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.AZURE_NA); +// Context appContext = ApplicationProvider.getApplicationContext(); +// stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); +// } } diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/EntryTestCase.java b/contentstack/src/androidTest/java/com/contentstack/sdk/EntryInstrumentedTest.java similarity index 94% rename from contentstack/src/androidTest/java/com/contentstack/sdk/EntryTestCase.java rename to contentstack/src/androidTest/java/com/contentstack/sdk/EntryInstrumentedTest.java index dc1fb492..4d57efde 100644 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/EntryTestCase.java +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/EntryInstrumentedTest.java @@ -1,26 +1,33 @@ package com.contentstack.sdk; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertTrue; + import android.content.Context; import android.util.Log; +import androidx.test.platform.app.InstrumentationRegistry; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import org.junit.*; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; import org.junit.runners.MethodSorters; import java.util.ArrayList; import java.util.concurrent.CountDownLatch; -import static junit.framework.TestCase.*; - -import androidx.test.core.app.ApplicationProvider; - @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class EntryTestCase { +public class EntryInstrumentedTest { - private final static String TAG = EntryTestCase.class.getSimpleName(); + private final static String TAG = EntryInstrumentedTest.class.getSimpleName(); private static String entryUID; private static final String CONTENT_TYPE_UID = BuildConfig.contentTypeUID; private static CountDownLatch latch; @@ -29,7 +36,8 @@ public class EntryTestCase { @BeforeClass public static void oneTimeSetUp() throws Exception { - Context appContext = ApplicationProvider.getApplicationContext(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + Config config = new Config(); String DEFAULT_HOST = BuildConfig.host; config.setHost(DEFAULT_HOST); @@ -46,20 +54,12 @@ public static void oneTimeTearDown() { Log.d(TAG, "Total testcase: " + latch.getCount()); } - /** - * Sets up the test fixture. - * (Called before every test case method.) - */ @Before public void setUp() { latch = new CountDownLatch(1); } - /** - * Tears down the test fixture. - * (Called after every test case method.) - */ @After public void tearDown() { Log.d(TAG, "Runs after every testcase completes."); diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/QueryTestCase.java b/contentstack/src/androidTest/java/com/contentstack/sdk/QueryInstrumentedTest.java similarity index 98% rename from contentstack/src/androidTest/java/com/contentstack/sdk/QueryTestCase.java rename to contentstack/src/androidTest/java/com/contentstack/sdk/QueryInstrumentedTest.java index d5217610..286afb1b 100644 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/QueryTestCase.java +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/QueryInstrumentedTest.java @@ -1,31 +1,34 @@ package com.contentstack.sdk; +import static junit.framework.TestCase.assertEquals; + import android.content.Context; import android.util.Log; +import androidx.test.platform.app.InstrumentationRegistry; + import org.json.JSONArray; import org.json.JSONObject; -import org.junit.*; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import static junit.framework.TestCase.assertEquals; -import androidx.test.core.app.ApplicationProvider; +public class QueryInstrumentedTest { - -public class QueryTestCase { - - private static final String TAG = AssetTestCase.class.getSimpleName(); + private static final String TAG = QueryInstrumentedTest.class.getSimpleName(); private static Stack stack; private static Query query; private static final String contentTypeUID = BuildConfig.contentTypeUID; @BeforeClass public static void oneTimeSetUp() throws Exception { - Context appContext = ApplicationProvider.getApplicationContext(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + Config config = new Config(); String DEFAULT_API_KEY = BuildConfig.APIKey; String DEFAULT_DELIVERY_TOKEN = BuildConfig.deliveryToken; @@ -37,10 +40,6 @@ public static void oneTimeSetUp() throws Exception { } - /** - * Sets up the test fixture. - * (Called before every test case method.) - */ @Before public void setUp() { query = stack.contentType(contentTypeUID).query(); diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/SyncInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/SyncInstrumentedTest.java new file mode 100644 index 00000000..2d77d28c --- /dev/null +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/SyncInstrumentedTest.java @@ -0,0 +1,238 @@ +package com.contentstack.sdk; + +import android.content.Context; +import android.util.Log; + +import androidx.test.platform.app.InstrumentationRegistry; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.LinkedHashMap; +import java.util.concurrent.CountDownLatch; + + +public class SyncInstrumentedTest { + + static final String TAG = SyncInstrumentedTest.class.getSimpleName(); + private static CountDownLatch latch; + private static Stack stack; + private final LinkedHashMap imageParams = new LinkedHashMap<>(); + private final String IMAGE_URL = "https://images.contentstack.io/v3/assets/download"; + + + @BeforeClass + public static void oneTimeSetUp() throws Exception { + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + + 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); + stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); + + latch = new CountDownLatch(1); + } + + @Before + public void setUp() { + latch = new CountDownLatch(1); + } + + + @Test + public void test_00_fetchAllImageTransformation() { + + imageParams.put("auto", "webp"); + imageParams.put("quality", 200); + imageParams.put("width", 100); + imageParams.put("height", 50); + imageParams.put("format", "png"); + imageParams.put("crop", "3:5"); + imageParams.put("trim", "20,20,20,20"); + imageParams.put("disable", "upscale"); + imageParams.put("pad", "10,10,10,10"); + imageParams.put("bg-color", "#FFFFFF"); + imageParams.put("dpr", 20); + imageParams.put("canvas", "3:5"); + imageParams.put("orient", "l"); + + String image_url = stack.ImageTransform(IMAGE_URL, imageParams); + int counter = 0; + if (image_url.contains("?")) { + String[] imgKeys = image_url.split("\\?"); + String rightUrl = imgKeys[1]; + String[] getAllPairs = rightUrl.split("\\&"); + counter = 0; + if (imageParams.size() > 0) { + for (int i = 0; i < imageParams.size(); i++) { + String keyValueParis = getAllPairs[i]; + Log.i(TAG, "pairs:--> " + keyValueParis); + ++counter; + } + } + } else { + try { + latch.await(); + } catch (Exception e) { + Log.i(TAG, "---------------||" + e.toString()); + } + } + + if (counter == imageParams.size()) { + latch.countDown(); + Log.i(TAG, "Testcases Passed"); + } else { + Log.i(TAG, "Testcases Failed"); + try { + latch.await(); + } catch (Exception e) { + Log.i(TAG, "---------------||" + e.toString()); + } + } + } + + + @Test + public void test_01_fetchAllImageTransformation() { + + imageParams.put("auto", "webp"); + imageParams.put("quality", 200); + imageParams.put("width", 100); + imageParams.put("height", 50); + imageParams.put("format", "png"); + imageParams.put("crop", "3:5"); + + String image_url = stack.ImageTransform(IMAGE_URL, imageParams); + int counter = 0; + /* check url contains "?" */ + if (image_url.contains("?")) { + String[] imgKeys = image_url.split("\\?"); + String rightUrl = imgKeys[1]; + String[] getAllPairs = rightUrl.split("\\&"); + counter = 0; + if (imageParams.size() > 0) { + for (int i = 0; i < imageParams.size(); i++) { + String keyValueParis = getAllPairs[i]; + Log.i(TAG, "pairs:--> " + keyValueParis); + ++counter; + } + } + } else { + Log.i(TAG, "Testcases Failed"); + try { + latch.await(); + } catch (Exception e) { + Log.i(TAG, "---------------||" + e.toString()); + } + } + + if (counter == imageParams.size()) { + latch.countDown(); + Log.i(TAG, "Testcases Passed"); + } else { + Log.i(TAG, "Testcases Failed"); + try { + latch.await(); + } catch (Exception e) { + Log.i(TAG, "---------------||" + e.toString()); + } + } + } + + + @Test + public void test_02_fetchAllImageTransformation() { + imageParams.put("trim", "20,20,20,20"); + imageParams.put("disable", "upscale"); + imageParams.put("pad", "10,10,10,10"); + imageParams.put("bg-color", "#FFFFFF"); + imageParams.put("dpr", 20); + imageParams.put("canvas", "3:5"); + imageParams.put("orient", "l"); + String image_url = stack.ImageTransform(IMAGE_URL, imageParams); + int counter = 0; + /* check url contains "?" */ + if (image_url.contains("?")) { + String[] imgKeys = image_url.split("\\?"); + String rightUrl = imgKeys[1]; + String[] getAllPairs = rightUrl.split("\\&"); + if (imageParams.size() > 0) { + for (int i = 0; i < imageParams.size(); i++) { + String keyValueParis = getAllPairs[i]; + Log.i(TAG, "pairs:--> " + keyValueParis); + ++counter; + } + } + } else { + Log.i(TAG, "Testcases Failed"); + try { + latch.await(); + } catch (Exception e) { + Log.i(TAG, "---------------||" + e.toString()); + } + } + + if (counter == imageParams.size()) { + latch.countDown(); + Log.i(TAG, "Testcases Passed"); + } else { + Log.i(TAG, "Testcases Failed"); + try { + latch.await(); + } catch (Exception e) { + Log.i(TAG, "---------------||" + e.toString()); + } + } + } + + + @Test + public void test_03_fetchAllImageTransformation() { + + + imageParams.put("trim", "20,20,20,20"); + imageParams.put("disable", "upscale"); + imageParams.put("canvas", "3:5"); + imageParams.put("orient", "l"); + + String image_url = stack.ImageTransform(IMAGE_URL, imageParams); + int counter = 0; + /* check url contains "?" */ + if (image_url.contains("?")) { + String[] imgKeys = image_url.split("\\?"); + String rightUrl = imgKeys[1]; + String[] getAllPairs = rightUrl.split("\\&"); + counter = 0; + if (imageParams.size() > 0) { + for (int i = 0; i < imageParams.size(); i++) { + String keyValueParis = getAllPairs[i]; + Log.i(TAG, "pairs:--> " + keyValueParis); + ++counter; + } + } + } else { + Log.i(TAG, "Testcases Failed"); + try { + latch.await(); + } catch (Exception e) { + Log.i(TAG, "---------------||" + e.toString()); + } + } + + if (counter == imageParams.size()) { + latch.countDown(); + Log.i(TAG, "Testcases Passed"); + } else { + Log.i(TAG, "Testcases Failed"); + try { + latch.await(); + } catch (Exception e) { + Log.i(TAG, "---------------||" + e.toString()); + } + } + } +} diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/TransformTestcase.java b/contentstack/src/androidTest/java/com/contentstack/sdk/TransformInstrumentedTest.java similarity index 95% rename from contentstack/src/androidTest/java/com/contentstack/sdk/TransformTestcase.java rename to contentstack/src/androidTest/java/com/contentstack/sdk/TransformInstrumentedTest.java index 7e60cfcb..af47f4c1 100644 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/TransformTestcase.java +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/TransformInstrumentedTest.java @@ -3,20 +3,19 @@ import android.content.Context; import android.util.Log; -import androidx.test.core.app.ApplicationProvider; +import androidx.test.platform.app.InstrumentationRegistry; -import org.junit.*; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.LinkedHashMap; import java.util.concurrent.CountDownLatch; -/** - * - */ -public class TransformTestcase { +public class TransformInstrumentedTest { - static final String TAG = TransformTestcase.class.getSimpleName(); + static final String TAG = TransformInstrumentedTest.class.getSimpleName(); private static CountDownLatch latch; private static Stack stack; private final LinkedHashMap imageParams = new LinkedHashMap<>(); @@ -25,7 +24,7 @@ public class TransformTestcase { @BeforeClass public static void oneTimeSetUp() throws Exception { - Context appContext = ApplicationProvider.getApplicationContext(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); Config config = new Config(); String DEFAULT_API_KEY = BuildConfig.APIKey; diff --git a/contentstack/src/main/AndroidManifest.xml b/contentstack/src/main/AndroidManifest.xml index 62a04f3d..15c759bf 100755 --- a/contentstack/src/main/AndroidManifest.xml +++ b/contentstack/src/main/AndroidManifest.xml @@ -7,22 +7,19 @@ - - - - - - - - - - + + + + + + + + + + + + + diff --git a/contentstack/src/main/java/com/contentstack/sdk/Asset.java b/contentstack/src/main/java/com/contentstack/sdk/Asset.java index 26c2173f..66446fad 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Asset.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Asset.java @@ -390,61 +390,52 @@ public void setCachePolicy(CachePolicy cachePolicy) { * */ public void fetch(FetchResultCallback callback) { - try { - - String URL = "/" + stackInstance.VERSION + "/assets/" + assetUid; + String urlEndpoint = "/" + stackInstance.VERSION + "/assets/" + assetUid; ArrayMap headers = getHeader(headerGroup_local); if (headers.containsKey("environment")) { urlQueries.put("environment", headers.get("environment")); } - - String mainStringForMD5 = URL + new JSONObject().toString() + headers.toString(); + String mainStringForMD5 = urlEndpoint + new JSONObject().toString() + headers.toString(); String md5Value = new CSAppUtils().getMD5FromString(mainStringForMD5.trim()); File cacheFile = new File(CSAppConstants.cacheFolderName + File.separator + md5Value); switch (cachePolicyForCall) { - case IGNORE_CACHE: - + fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); + break; case NETWORK_ONLY: - fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), callback); + fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); break; - case CACHE_ONLY: fetchFromCache(cacheFile, callback); break; - case CACHE_ELSE_NETWORK: - if (cacheFile.exists()) { boolean needToSendCall = false; needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); if (needToSendCall) { - fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), callback); + fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); } else { setCacheModel(cacheFile, callback); } } else { - fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), callback); + fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); } break; case CACHE_THEN_NETWORK: if (cacheFile.exists()) { setCacheModel(cacheFile, callback); } - // from network - fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), callback); + fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); break; case NETWORK_ELSE_CACHE: - if (CSAppConstants.isNetworkAvailable) { - fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), callback); + fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); } else { fetchFromCache(cacheFile, callback); } - break; } diff --git a/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java b/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java index 6c5888e0..a029629f 100644 --- a/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java +++ b/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java @@ -25,7 +25,7 @@ */ public class AssetLibrary implements INotifyClass { - private final static String TAG = "AssetLibrary"; + private final static String TAG = AssetLibrary.class.getSimpleName(); private Stack stackInstance; private ArrayMap stackHeader; private ArrayMap localHeader; @@ -34,7 +34,7 @@ public class AssetLibrary implements INotifyClass { private int count; private static CachePolicy cachePolicyForCall = CachePolicy.IGNORE_CACHE; private long maxCacheTimeForCall = 0; - private long defaultCacheTimeInterval = 0; + private final long defaultCacheTimeInterval = 0; /** * Sorting order enum for {@link AssetLibrary}. @@ -440,4 +440,13 @@ public AssetLibrary includeFallback() { return this; } + public AssetLibrary includeMetadata() { + try { + urlQueries.put("include_metadata", true); + } catch (JSONException e) { + Log.e(TAG, e.getLocalizedMessage()); + } + return this; + } + } diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java b/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java index 14458615..13931de5 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java @@ -18,7 +18,7 @@ public CSBackgroundTask(Query queryInstance, Stack stackInstance, String control if (CSAppConstants.isNetworkAvailable) { if (headers != null && headers.size() > 0) { - String URL = stackInstance.URLSCHEMA + stackInstance.URL + url; + String URL = stackInstance.PROTOCOL + stackInstance.URL + url; CSConnectionRequest csConnectionRequest = new CSConnectionRequest(queryInstance); csConnectionRequest.setQueryInstance(queryInstance); @@ -37,7 +37,7 @@ public CSBackgroundTask(Entry entryInstance, Stack stackInstance, String control if (CSAppConstants.isNetworkAvailable) { if (headers != null && headers.size() > 0) { - String URL = stackInstance.URLSCHEMA + stackInstance.URL + url; + String URL = stackInstance.PROTOCOL + stackInstance.URL + url; CSConnectionRequest csConnectionRequest = new CSConnectionRequest(entryInstance); csConnectionRequest.setURLQueries(urlQueries); @@ -55,7 +55,7 @@ public CSBackgroundTask(AssetLibrary assetLibrary, Stack stackInstance, String c if (CSAppConstants.isNetworkAvailable) { if (headers != null && headers.size() > 0) { - String URL = stackInstance.URLSCHEMA + stackInstance.URL + url; + String URL = stackInstance.PROTOCOL + stackInstance.URL + url; CSConnectionRequest csConnectionRequest = new CSConnectionRequest(assetLibrary); csConnectionRequest.setURLQueries(urlQueries); @@ -73,7 +73,7 @@ public CSBackgroundTask(Asset asset, Stack stackInstance, String controller, Str if (CSAppConstants.isNetworkAvailable) { if (headers != null && headers.size() > 0) { - String URL = stackInstance.URLSCHEMA + stackInstance.URL + url; + String URL = stackInstance.PROTOCOL + stackInstance.URL + url; CSConnectionRequest csConnectionRequest = new CSConnectionRequest(asset); csConnectionRequest.setURLQueries(urlQueries); @@ -93,7 +93,7 @@ public CSBackgroundTask(Stack stack, Stack stackInstance, String controller, Str if (CSAppConstants.isNetworkAvailable) { if (headers != null && headers.size() > 0) { - String URL = stackInstance.URLSCHEMA + stackInstance.URL + url; + String URL = stackInstance.PROTOCOL + stackInstance.URL + url; CSConnectionRequest csConnectionRequest = new CSConnectionRequest(stack); csConnectionRequest.setStackInstance(stack); @@ -114,7 +114,7 @@ public CSBackgroundTask(ContentType contentType, Stack stackInstance, String con if (CSAppConstants.isNetworkAvailable) { if (headers != null && headers.size() > 0) { - String URL = stackInstance.URLSCHEMA + stackInstance.URL + url; + String URL = stackInstance.PROTOCOL + stackInstance.URL + url; CSConnectionRequest csConnectionRequest = new CSConnectionRequest(contentType); csConnectionRequest.setContentTypeInstance(contentType); diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java index e1a9ecc5..694ce706 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java @@ -1,7 +1,7 @@ package com.contentstack.sdk; -import android.util.ArrayMap; import android.text.TextUtils; +import android.util.ArrayMap; import android.util.Log; import com.android.volley.DefaultRetryPolicy; @@ -240,17 +240,13 @@ public void send() { url = urlPath; } - for (Map.Entry entry : this.headers.entrySet()) { String key = entry.getKey(); headers.put(key, (String) entry.getValue()); } - headers.put("Content-Type", "application/json"); headers.put("User-Agent", defaultUserAgent()); headers.put("X-User-Agent", "contentstack-android/" + CSAppConstants.SDK_VERSION); - - System.out.println(headers); jsonObjectRequest = new JSONUTF8Request(requestId, url, requestJSON, response -> { responseJSON = response; Log.i("response", response.toString()); diff --git a/contentstack/src/main/java/com/contentstack/sdk/Config.java b/contentstack/src/main/java/com/contentstack/sdk/Config.java index 30449e57..104507d1 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Config.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Config.java @@ -2,8 +2,6 @@ import android.text.TextUtils; -import com.contentstack.sdk.utilities.CSAppConstants; - /** * Set Configuration for stack instance creation. * @@ -11,19 +9,12 @@ */ public class Config { - protected String URLSCHEMA = "https://"; + protected String PROTOCOL = "https://"; protected String URL = "cdn.contentstack.io"; protected String VERSION = "v3"; protected String environment = null; protected ContentstackRegion region = ContentstackRegion.US; - public enum ContentstackRegion {US, EU, AZURE_NA} - - - public ContentstackRegion getRegion() { - return this.region; - } - /** * Sets region allow you to set your region for the Contentstack server. * @@ -32,8 +23,8 @@ public ContentstackRegion getRegion() { * *

Example :
*
-     *                                                                                                   config.setRegion(ContentstackRegion.US);
-     *                                                                                                   
+ * config.setRegion(ContentstackRegion.US); + * */ public ContentstackRegion setRegion(ContentstackRegion region) { @@ -41,6 +32,13 @@ public ContentstackRegion setRegion(ContentstackRegion region) { return this.region; } + + public ContentstackRegion getRegion() { + return this.region; + } + + public enum ContentstackRegion {US, EU, AZURE_NA, AZURE_EU} + /** * Config constructor * diff --git a/contentstack/src/main/java/com/contentstack/sdk/Entry.java b/contentstack/src/main/java/com/contentstack/sdk/Entry.java index 0df401e5..5d90f028 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Entry.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Entry.java @@ -1,7 +1,7 @@ package com.contentstack.sdk; -import android.util.ArrayMap; import android.text.TextUtils; +import android.util.ArrayMap; import android.util.Log; import com.contentstack.sdk.utilities.CSAppConstants; @@ -102,10 +102,10 @@ public Entry configure(JSONObject jsonObject) { * *

Example :
*
-     *                           Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken",  "stag");
-     *                           Entry entry = stack.contentType("form_name").entry("entry_uid");
-     *                           entry.setHeader("custom_header_key", "custom_header_value");
-     *                           
+ * Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "stag"); + * Entry entry = stack.contentType("form_name").entry("entry_uid"); + * entry.setHeader("custom_header_key", "custom_header_value"); + * */ public void setHeader(String key, String value) { if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) { @@ -120,10 +120,10 @@ public void setHeader(String key, String value) { * *

Example :
*
-     *                       Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken",  "stag");
-     *                       Entry entry = stack.contentType("form_name").entry("entry_uid");
-     *                       entry.removeHeader("custom_header_key");
-     *                       
+ * Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "stag"); + * Entry entry = stack.contentType("form_name").entry("entry_uid"); + * entry.removeHeader("custom_header_key"); + * */ public void removeHeader(String key) { if (!TextUtils.isEmpty(key)) { @@ -304,8 +304,8 @@ public JSONObject toJSON() { * *

Example :
*
-     *                       Object obj = entry.get("key");
-     *                       
+ * Object obj = entry.get("key"); + * */ public Object get(String key) { try { @@ -372,8 +372,8 @@ public ArrayList getMultipleHtmlText(String markdownKey) { * *

Example :
*
-     *                       String value = entry.getString("key");
-     *                       
+ * String value = entry.getString("key"); + * */ public String getString(String key) { Object value = get(key); @@ -392,8 +392,8 @@ public String getString(String key) { * *

Example :
*
-     *                       Boolean value = entry.getBoolean("key");
-     *                       
+ * Boolean value = entry.getBoolean("key"); + * */ public Boolean getBoolean(String key) { Object value = get(key); @@ -412,8 +412,8 @@ public Boolean getBoolean(String key) { * *

Example :
*
-     *                       JSONArray value = entry.getJSONArray("key");
-     *                       
+ * JSONArray value = entry.getJSONArray("key"); + * */ public JSONArray getJSONArray(String key) { Object value = get(key); @@ -432,8 +432,8 @@ public JSONArray getJSONArray(String key) { * *

Example :
*
-     *                       JSONObject value = entry.getJSONObject("key");
-     *                       
+ * JSONObject value = entry.getJSONObject("key"); + * */ public JSONObject getJSONObject(String key) { Object value = get(key); @@ -452,8 +452,8 @@ public JSONObject getJSONObject(String key) { * *

Example :
*
-     *                       JSONObject value = entry.getJSONObject("key");
-     *                       
+ * JSONObject value = entry.getJSONObject("key"); + * */ public Number getNumber(String key) { Object value = get(key); @@ -472,8 +472,8 @@ public Number getNumber(String key) { * *

Example :
*
-     *                       int value = entry.getInt("key");
-     *                       
+ * int value = entry.getInt("key"); + * */ public int getInt(String key) { Number value = getNumber(key); @@ -490,8 +490,8 @@ public int getInt(String key) { * *

Example :
*
-     *                       float value = entry.getFloat("key");
-     *                       
+ * float value = entry.getFloat("key"); + * */ public float getFloat(String key) { Number value = getNumber(key); @@ -508,8 +508,8 @@ public float getFloat(String key) { * *

Example :
*
-     *                       double value = entry.getDouble("key");
-     *                       
+ * double value = entry.getDouble("key"); + * */ public double getDouble(String key) { Number value = getNumber(key); @@ -526,8 +526,8 @@ public double getDouble(String key) { * *

Example :
*
-     *                       long value = entry.getLong("key");
-     *                       
+ * long value = entry.getLong("key"); + * */ public long getLong(String key) { Number value = getNumber(key); @@ -544,8 +544,8 @@ public long getLong(String key) { * *

Example :
*
-     *                       short value = entry.getShort("key");
-     *                       
+ * short value = entry.getShort("key"); + * */ public short getShort(String key) { Number value = getNumber(key); @@ -562,8 +562,8 @@ public short getShort(String key) { * *

Example :
*
-     *                       Calendar value = entry.getDate("key");
-     *                       
+ * Calendar value = entry.getDate("key"); + * */ public Calendar getDate(String key) { @@ -681,8 +681,8 @@ public String getDeletedBy() { * *

Example :
*
-     *                       Asset asset = entry.getAsset("key");
-     *                       
+ * Asset asset = entry.getAsset("key"); + * */ public Asset getAsset(String key) { @@ -699,8 +699,8 @@ public Asset getAsset(String key) { * *

Example :
*
-     *                       List asset = entry.getAssets("key");
-     *                       
+ * List asset = entry.getAssets("key"); + * */ public List getAssets(String key) { List assets = new ArrayList<>(); @@ -722,8 +722,8 @@ public List getAssets(String key) { * *

Example :
*
-     *                       Group innerGroup = entry.getGroup("key");
-     *                       
+ * Group innerGroup = entry.getGroup("key"); + * */ public Group getGroup(String key) { @@ -743,8 +743,8 @@ public Group getGroup(String key) { * *

Example :
*
-     *                       Group innerGroup = entry.getGroups("key");
-     *                       
+ * Group innerGroup = entry.getGroups("key"); + * */ public List getGroups(String key) { @@ -1061,14 +1061,14 @@ protected void setUid(String uid) { * *

Example :
*
-     *                                    Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken",  "stag");
-     *                                    Entry entry = stack.contentType("form_name").entry("entry_uid");
- * entry.fetch(new BuiltResultCallBack() {
- * @Override - * public void onCompletion(ResponseType responseType, BuiltError builtError) { - * - * }
- * });
+ * Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "stag"); + * Entry entry = stack.contentType("form_name").entry("entry_uid");
+ * entry.fetch(new BuiltResultCallBack() {
+ * @Override + * public void onCompletion(ResponseType responseType, BuiltError builtError) { + * + * }
+ * });
*/ public void fetch(EntryResultCallBack callBack) { try { @@ -1111,28 +1111,17 @@ public void fetch(EntryResultCallBack callBack) { break; case CACHE_ELSE_NETWORK: - if (cacheFile.exists()) { boolean needToSendCall = false; - - // if (maxCacheTimeForCall > 0) { - // needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); - // } else { - // needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) defaultCacheTimeInterval); - // } needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); - if (needToSendCall) { fetchFromNetwork(URL, urlQueries, cacheFile.getPath(), callBack); - } else { setCacheModel(cacheFile, callBack); } - } else { fetchFromNetwork(URL, urlQueries, cacheFile.getPath(), callBack); } - break; case CACHE_THEN_NETWORK: @@ -1500,4 +1489,13 @@ public Entry includeEmbeddedItems() { } return this; } + + public Entry includeMetadata() { + try { + otherPostJSON.put("include_metadata", true); + } catch (JSONException e) { + Log.e(TAG, e.getLocalizedMessage()); + } + return this; + } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/EntryModel.java b/contentstack/src/main/java/com/contentstack/sdk/EntryModel.java index e8ccbc0d..a0b7c729 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/EntryModel.java +++ b/contentstack/src/main/java/com/contentstack/sdk/EntryModel.java @@ -5,7 +5,6 @@ import org.json.JSONArray; import org.json.JSONObject; -import java.util.HashMap; import java.util.Iterator; import java.util.WeakHashMap; @@ -75,20 +74,9 @@ public EntryModel(JSONObject jsonObj, String entryUid, boolean isFromObjectsMode _metadata.put(key, _metadataJSON.optString(key)); } } else if (jsonObject != null && jsonObject.has("publish_details")) { - - JSONArray publishArray = jsonObject.optJSONArray("publish_details"); - for (int i = 0; i < publishArray.length(); i++) { - JSONObject jsonObject = publishArray.optJSONObject(i); - Iterator iterator = jsonObject.keys(); - HashMap hashMap = new HashMap<>(); - while (iterator.hasNext()) { - String key = iterator.next(); - hashMap.put(key, jsonObject.opt(key)); - } - } - + JSONObject publishDetailsObj = jsonObject.optJSONObject("publish_details"); _metadata = new WeakHashMap<>(); - _metadata.put("publish_details", publishArray); + _metadata.put("publish_details", publishDetailsObj); } diff --git a/contentstack/src/main/java/com/contentstack/sdk/InvalidInputException.java b/contentstack/src/main/java/com/contentstack/sdk/InvalidInputException.java new file mode 100644 index 00000000..37720f1f --- /dev/null +++ b/contentstack/src/main/java/com/contentstack/sdk/InvalidInputException.java @@ -0,0 +1,32 @@ +package com.contentstack.sdk; + + +/** + * This class extends the Exception class, which is the base class for all checked exceptions in Java. + * The InvalidInputException class takes a String message as input and passes it to the + * Exception class constructor using the super keyword. + *

+ * You can use this custom exception class to throw an exception when invalid input is detected in your code. + *

For example: + *

+ * + * + * public void processInput(String input) throws InvalidInputException { + * if (input == null || input.isEmpty()) { + * throw new InvalidInputException("Input cannot be null or empty"); + * } + * // Process the input here + * } + * + */ +public class InvalidInputException extends Exception { + /** + * Instantiates a new Invalid input exception. + * + * @param message the message + */ + public InvalidInputException(String message) { + super(message); + } +} + diff --git a/contentstack/src/main/java/com/contentstack/sdk/Query.java b/contentstack/src/main/java/com/contentstack/sdk/Query.java index 9bb7441f..cf9a8f94 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Query.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Query.java @@ -2021,5 +2021,14 @@ public Query includeEmbeddedItems() { return this; } + public Query includeMetadata() { + try { + urlQueries.put("include_metadata", true); + } catch (JSONException e) { + Log.e(TAG, e.getLocalizedMessage()); + } + return this; + } + } diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index 3699d860..40796a0b 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -1,7 +1,7 @@ package com.contentstack.sdk; -import android.util.ArrayMap; import android.text.TextUtils; +import android.util.ArrayMap; import android.util.Log; import com.contentstack.sdk.utilities.CSAppConstants; @@ -23,6 +23,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.TimeZone; /** @@ -38,7 +39,7 @@ public class Stack implements INotifyClass { protected ArrayMap localHeader = null; private String imageTransformationUrl; private LinkedHashMap imageParams = new LinkedHashMap<>(); - protected String URLSCHEMA = "https://"; + protected String PROTOCOL = "https://"; protected String URL = "cdn.contentstack.io"; protected String VERSION = "v3"; protected String SYNC_KEY = "sync"; @@ -47,30 +48,14 @@ public class Stack implements INotifyClass { private JSONObject syncParams = null; protected String skip = null; protected String limit = null; - protected String sync_token = null; - protected String pagination_token = null; - protected String contentType; protected String localeCode; - protected PublishType publishType; - protected String startFromDate; private SyncResultCallBack syncCallBack; - public enum PublishType { - entry_published, - entry_unpublished, - entry_deleted, - asset_published, - asset_unpublished, - asset_deleted, - content_type_deleted - } - - - private Stack() { + private Stack() throws IllegalAccessException { + throw new IllegalAccessException("Can not initialise using constructor"); } - protected Stack(String stackApiKey) { this.stackApiKey = stackApiKey; this.localHeader = new ArrayMap(); @@ -79,7 +64,7 @@ protected Stack(String stackApiKey) { protected void setConfig(Config config) { this.config = config; - URLSCHEMA = config.URLSCHEMA; + PROTOCOL = config.PROTOCOL; URL = config.URL; VERSION = config.VERSION; @@ -95,6 +80,8 @@ protected void setConfig(Config config) { } if (region.equalsIgnoreCase("azure_na")) { URL = "azure-na-cdn.contentstack.com"; + } else if (region.equalsIgnoreCase("azure_eu")) { + URL = "azure-eu-cdn.contentstack.com"; } else { URL = region + "-" + URL; } @@ -103,6 +90,28 @@ protected void setConfig(Config config) { } + /** + * @param syncCallBack returns callback for sync result. + *

+ *

+ * The Sync request performs a complete sync of your app data. + * 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. + *

+ */ + + public void sync(SyncResultCallBack syncCallBack) { + try { + syncParams = new JSONObject(); + syncParams.put("init", true); + } catch (JSONException e) { + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); + } + this.requestSync(syncCallBack); + + } + /** * Represents a {@link ContentType}.
* Create {@link ContentType} instance. @@ -357,84 +366,42 @@ public void getContentTypes(JSONObject params, final ContentTypesCallback callba private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap headers, String cacheFilePath, ContentTypesCallback callback) { - if (callback != null) { - HashMap urlParams = getUrlParams(urlQueries); new CSBackgroundTask(this, this, CSController.FETCHCONTENTTYPES, urlString, headers, urlParams, new JSONObject(), cacheFilePath, CSAppConstants.callController.CONTENTTYPES.toString(), false, CSAppConstants.RequestMethod.GET, callback); } } - /** - * @param syncCallBack returns callback for sync result. - *

- *

- * The Sync request performs a complete sync of your app data. - * 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 :
- *

-     *
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                     stack.sync(SyncResultCallBack syncCallBack){  }
-     *
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                     
+ * @param paginationToken If the response is paginated, use the pagination token under this parameter. + * @param syncCallBack returns callback for sync result + *

+ * If the result of the initial sync (or subsequent sync) contains more than 100 records, + * the response would be paginated. It provides pagination token in the response. However, + * you do not have to use the pagination token manually to get the next batch, + * the SDK does that automatically until the sync is complete. + * Pagination token can be used in case you want to fetch only selected batches. + * It is especially useful if the sync process is interrupted midway (due to network issues, etc.). + * In such cases, this token can be used to restart the sync process from where it was interrupted. + * + * + * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} + * + * + * */ - - public void sync(SyncResultCallBack syncCallBack) { - - if (syncParams == null) { - syncParams = new JSONObject(); - } + public void syncPaginationToken(String paginationToken, SyncResultCallBack syncCallBack) { try { - syncParams.put("init", true); - } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); - } - - this.requestSync(syncCallBack); - - } - - - /** - * @param pagination_token If the response is paginated, use the pagination token under this parameter. - * @param syncCallBack returns callback for sync result - *

- * If the result of the initial sync (or subsequent sync) contains more than 100 records, - * the response would be paginated. It provides pagination token in the response. However, - * you do not have to use the pagination token manually to get the next batch, - * the SDK does that automatically until the sync is complete. - * Pagination token can be used in case you want to fetch only selected batches. - * It is especially useful if the sync process is interrupted midway (due to network issues, etc.). - * In such cases, this token can be used to restart the sync process from where it was interrupted. - * - *

Example :
- *

-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {}
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
- */ - public void syncPaginationToken(String pagination_token, SyncResultCallBack syncCallBack) { - this.pagination_token = pagination_token; - if (syncParams == null) { syncParams = new JSONObject(); - } - - try { - syncParams.put("init", true); - syncParams.put("pagination_token", pagination_token); + syncParams.put("pagination_token", paginationToken); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } - this.requestSync(syncCallBack); } - /** - * @param sync_token Use the sync token that you received in the previous/initial sync under this parameter. + * @param syncToken Use the sync token that you received in the previous/initial sync under this parameter. * @param syncCallBack returns callback for sync result *

* You can use the sync token (that you receive after initial sync) to get the updated content next time. @@ -442,29 +409,22 @@ public void syncPaginationToken(String pagination_token, SyncResultCallBack sync * and the details of the content that was deleted or updated. *

Example :
*

-     *                                                                                                                                                                                                                                                                                                                                                                                                                                      stack.syncToken(sync_token, new SyncResultCallBack() ){ }
+     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  stack.syncToken(sync_token, new SyncResultCallBack() ){ }
      *
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                     
+ * */ - public void syncToken(String sync_token, SyncResultCallBack syncCallBack) { - - this.sync_token = sync_token; - if (syncParams == null) { - syncParams = new JSONObject(); - } + public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { try { - syncParams.put("init", true); - syncParams.put("sync_token", sync_token); + syncParams = new JSONObject(); + syncParams.put("sync_token", syncToken); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } - this.requestSync(syncCallBack); } - /** - * @param from_date Enter the start date for initial sync. + * @param fromDate Enter the start date for initial sync. * @param syncCallBack Returns callback for sync result. *

* You can also initialize sync with entries published after a specific date. To do this, use syncWithDate @@ -472,67 +432,49 @@ public void syncToken(String sync_token, SyncResultCallBack syncCallBack) { * *

Example :
*

-     *                                                                                                                                                                                                                                                                                                                                                                                                                                    stack.syncFromDate(start_date, new SyncResultCallBack()) { }
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                      
+ * stack.syncFromDate(start_date, new SyncResultCallBack()) { } + * */ - public void syncFromDate(Date from_date, SyncResultCallBack syncCallBack) { - startFromDate = convertUTCToISO(from_date); - if (syncParams == null) { - syncParams = new JSONObject(); - } - + public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { + String startFromDate = convertUTCToISO(fromDate); try { + syncParams = new JSONObject(); syncParams.put("init", true); syncParams.put("start_from", startFromDate); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } this.requestSync(syncCallBack); } - - private String convertUTCToISO(Date date) { - - TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); - dateFormat.setTimeZone(tz); - return dateFormat.format(date); - } - - /** - * @param content_type Provide uid of your content_type + * @param contentType Provide uid of your content_type * @param syncCallBack Returns callback for sync result. *

* You can also initialize sync with entries of only specific content_type. * 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. - * - *

Example :
- *

-     *
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                     // dummy content_type like "session"
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                     stack.syncContentType(String content_type, new SyncResultCallBack()){  }
-     *
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                      
+ *

*/ - public void syncContentType(String content_type, SyncResultCallBack syncCallBack) { - - this.contentType = content_type; - if (syncParams == null) { - syncParams = new JSONObject(); - } + public void syncContentType(String contentType, SyncResultCallBack syncCallBack) { try { + syncParams = new JSONObject(); syncParams.put("init", true); syncParams.put("content_type_uid", contentType); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } - this.requestSync(syncCallBack); } + private String convertUTCToISO(Date date) { + TimeZone tz = TimeZone.getTimeZone("UTC"); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); + dateFormat.setTimeZone(tz); + return dateFormat.format(date); + } + /** * @param language Select the required locale from the Language class. * @param syncCallBack Returns callback for sync result. @@ -542,22 +484,18 @@ public void syncContentType(String content_type, SyncResultCallBack syncCallBack * */ public void syncLocale(Language language, SyncResultCallBack syncCallBack) { - this.localeCode = getLanguageCode(language); - - if (syncParams == null) { - syncParams = new JSONObject(); - } + String localeCode = getLanguageCode(language); try { + syncParams = new JSONObject(); syncParams.put("init", true); syncParams.put("locale", localeCode); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } this.requestSync(syncCallBack); } - /** * @param localeCode Provide locale code * @param syncCallBack Returns callback for sync result. @@ -567,33 +505,17 @@ public void syncLocale(Language language, SyncResultCallBack syncCallBack) { * */ public void syncLocale(@NotNull String localeCode, SyncResultCallBack syncCallBack) { - if (syncParams == null) { - syncParams = new JSONObject(); - } try { + syncParams = new JSONObject(); syncParams.put("init", true); syncParams.put("locale", localeCode); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } this.requestSync(syncCallBack); } - - private String getLanguageCode(Language language) { - String localeCode = null; - if (language != null) { - Language languageName = Language.valueOf(language.name()); - int localeValue = languageName.ordinal(); - LanguageCode[] languageCodeValues = LanguageCode.values(); - localeCode = languageCodeValues[localeValue].name(); - localeCode = localeCode.replace("_", "-"); - } - return localeCode; - } - - /** * @param type - Use the type parameter to get a specific type of content * like ( asset_published, entry_published, asset_unpublished, asset_deleted, entry_unpublished, entry_deleted, content_type_deleted.) @@ -602,32 +524,39 @@ private String getLanguageCode(Language language) { * Use the type parameter to get a specific type of content. You can pass one of the following values: * asset_published, entry_published, asset_unpublished, asset_deleted, entry_unpublished, entry_deleted, content_type_deleted. * If you do not specify any value, it will bring all published entries and published assets. + *

+ * + * stackInstance.syncPublishType(Stack.PublishType.entry_published, new SyncResultCallBack()) { } + * * - *

Example :
- *

-     *
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                       stackInstance.syncPublishType(Stack.PublishType.entry_published, new SyncResultCallBack()) { }
-     *
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                      
+ * */ public void syncPublishType(PublishType type, SyncResultCallBack syncCallBack) { - this.publishType = type; - if (syncParams == null) { - syncParams = new JSONObject(); - } - try { + syncParams = new JSONObject(); syncParams.put("init", true); - syncParams.put("type", publishType); + syncParams.put("type", type); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } this.requestSync(syncCallBack); } + private String getLanguageCode(Language language) { + String localeCode = null; + if (language != null) { + Language languageName = Language.valueOf(language.name()); + int localeValue = languageName.ordinal(); + LanguageCode[] languageCodeValues = LanguageCode.values(); + localeCode = languageCodeValues[localeValue].name(); + localeCode = localeCode.replace("_", "-"); + } + return localeCode; + } + /** * @param contentType the content type * @param fromDate the from date @@ -640,19 +569,14 @@ public void syncPublishType(PublishType type, SyncResultCallBack syncCallBack) { */ public void sync(String contentType, Date fromDate, Language language, PublishType type, SyncResultCallBack syncCallBack) { - startFromDate = convertUTCToISO(fromDate); - this.contentType = contentType; - this.publishType = type; + String startFromDate = convertUTCToISO(fromDate); this.localeCode = getLanguageCode(language); - - if (syncParams == null) { - syncParams = new JSONObject(); - } try { + syncParams = new JSONObject(); syncParams.put("init", true); - syncParams.put("start_from", this.startFromDate); - syncParams.put("content_type_uid", this.contentType); - syncParams.put("type", publishType); + syncParams.put("start_from", startFromDate); + syncParams.put("content_type_uid", contentType); + syncParams.put("type", type); syncParams.put("locale", this.localeCode); } catch (JSONException e) { Log.e(TAG, e.getLocalizedMessage()); @@ -660,33 +584,40 @@ public void sync(String contentType, Date fromDate, Language language, PublishTy this.requestSync(syncCallBack); } - public void sync(String contentType, Date fromDate, String locale, PublishType type, SyncResultCallBack syncCallBack) { - startFromDate = convertUTCToISO(fromDate); - this.contentType = contentType; - this.publishType = type; - if (syncParams == null) { - syncParams = new JSONObject(); - } + String startFromDate = convertUTCToISO(fromDate); try { + syncParams = new JSONObject(); syncParams.put("init", true); - syncParams.put("start_from", this.startFromDate); - syncParams.put("content_type_uid", this.contentType); - syncParams.put("type", publishType); + syncParams.put("start_from", startFromDate); + syncParams.put("content_type_uid", contentType); + syncParams.put("type", type); syncParams.put("locale", locale); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } this.requestSync(syncCallBack); } - private void requestSync(final SyncResultCallBack callback) { + /** + * The enum Publish type. + */ + public enum PublishType { + ENTRY_PUBLISHED, + ENTRY_UNPUBLISHED, + ENTRY_DELETED, + ASSET_PUBLISHED, + ASSET_UNPUBLISHED, + ASSET_DELETED, + CONTENT_TYPE_DELETED + } + + private void requestSync(final SyncResultCallBack callback) { try { String URL = "/" + this.VERSION + "/stacks/" + SYNC_KEY; ArrayMap headers = getHeader(localHeader); - JSONObject urlQueries = new JSONObject(); if (headers.containsKey("environment")) { syncParams.put("environment", headers.get("environment")); @@ -704,14 +635,11 @@ public void onCompletion(SyncStack syncStack, Error error) { callback.onCompletion(syncStack, error); } }); - - } catch (Exception e) { Error error = new Error(); error.setErrorMessage(CSAppConstants.ErrorMessage_JsonNotProper); callback.onRequestFail(ResponseType.UNKNOWN, error); } - } diff --git a/contentstack/src/main/java/com/contentstack/sdk/package-info.java b/contentstack/src/main/java/com/contentstack/sdk/package-info.java new file mode 100755 index 00000000..dbbc6515 --- /dev/null +++ b/contentstack/src/main/java/com/contentstack/sdk/package-info.java @@ -0,0 +1,5 @@ +/** + * Okio complements {@link java.io} and {@link java.nio} to make it much easier to access, store, + * and process your data. + */ +package com.contentstack.sdk; diff --git a/contentstack/src/main/res/mipmap-hdpi/ic_launcher.png b/contentstack/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100755 index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3418 zcmZ{nX*|@A^T0p5j$I+^%FVhdvMbgt%d+mG98ubwNv_tpITppba^GiieBBZGI>I89 zGgm8TA>_)DlEu&W;s3#ZUNiH4&CF{a%siTjzG;eOzQB6{003qKeT?}z_5U*{{kgZ; zdV@U&tqa-&4FGisjMN8o=P}$t-`oTM2oeB5d9mHPgTYJx4jup)+5a;Tke$m708DocFzDL>U$$}s6FGiy_I1?O zHXq`q884|^O4Q*%V#vwxqCz-#8i`Gu)2LeB0{%%VKunOF%9~JcFB9MM>N00M`E~;o zBU%)O5u-D6NF~OQV7TV#JAN;=Lylgxy0kncoQpGq<<_gxw`FC=C-cV#$L|(47Hatl ztq3Jngq00x#}HGW@_tj{&A?lwOwrVX4@d66vLVyj1H@i}VD2YXd)n03?U5?cKtFz4 zW#@+MLeDVP>fY0F2IzT;r5*MAJ2}P8Z{g3utX0<+ZdAC)Tvm-4uN!I7|BTw&G%RQn zR+A5VFx(}r<1q9^N40XzP=Jp?i=jlS7}T~tB4CsWx!XbiHSm zLu}yar%t>-3jlutK=wdZhES->*1X({YI;DN?6R=C*{1U6%wG`0>^?u}h0hhqns|SeTmV=s;Gxx5F9DtK>{>{f-`SpJ`dO26Ujk?^%ucsuCPe zIUk1(@I3D^7{@jmXO2@<84|}`tDjB}?S#k$ik;jC))BH8>8mQWmZ zF#V|$gW|Xc_wmmkoI-b5;4AWxkA>>0t4&&-eC-J_iP(tLT~c6*(ZnSFlhw%}0IbiJ ztgnrZwP{RBd(6Ds`dM~k;rNFgkbU&Yo$KR#q&%Kno^YXF5ONJwGwZ*wEr4wYkGiXs z$&?qX!H5sV*m%5t@3_>ijaS5hp#^Pu>N_9Q?2grdNp({IZnt|P9Xyh);q|BuoqeUJ zfk(AGX4odIVADHEmozF|I{9j>Vj^jCU}K)r>^%9#E#Y6B0i#f^iYsNA!b|kVS$*zE zx7+P?0{oudeZ2(ke=YEjn#+_cdu_``g9R95qet28SG>}@Me!D6&}un*e#CyvlURrg8d;i$&-0B?4{eYEgzwotp*DOQ_<=Ai21Kzb0u zegCN%3bdwxj!ZTLvBvexHmpTw{Z3GRGtvkwEoKB1?!#+6h1i2JR%4>vOkPN_6`J}N zk}zeyY3dPV+IAyn;zRtFH5e$Mx}V(|k+Ey#=nMg-4F#%h(*nDZDK=k1snlh~Pd3dA zV!$BoX_JfEGw^R6Q2kpdKD_e0m*NX?M5;)C zb3x+v?J1d#jRGr=*?(7Habkk1F_#72_iT7{IQFl<;hkqK83fA8Q8@(oS?WYuQd4z^ z)7eB?N01v=oS47`bBcBnKvI&)yS8`W8qHi(h2na?c6%t4mU(}H(n4MO zHIpFdsWql()UNTE8b=|ZzY*>$Z@O5m9QCnhOiM%)+P0S06prr6!VET%*HTeL4iu~!y$pN!mOo5t@1 z?$$q-!uP(+O-%7<+Zn5i=)2OftC+wOV;zAU8b`M5f))CrM6xu94e2s78i&zck@}%= zZq2l!$N8~@63!^|`{<=A&*fg;XN*7CndL&;zE(y+GZVs-IkK~}+5F`?ergDp=9x1w z0hkii!N(o!iiQr`k`^P2LvljczPcM`%7~2n#|K7nJq_e0Ew;UsXV_~3)<;L?K9$&D zUzgUOr{C6VLl{Aon}zp`+fH3>$*~swkjCw|e>_31G<=U0@B*~hIE)|WSb_MaE41Prxp-2eEg!gcon$fN6Ctl7A_lV8^@B9B+G~0=IYgc%VsprfC`e zoBn&O3O)3MraW#z{h3bWm;*HPbp*h+I*DoB%Y~(Fqp9+x;c>K2+niydO5&@E?SoiX_zf+cI09%%m$y=YMA~rg!xP*>k zmYxKS-|3r*n0J4y`Nt1eO@oyT0Xvj*E3ssVNZAqQnj-Uq{N_&3e45Gg5pna+r~Z6^ z>4PJ7r(gO~D0TctJQyMVyMIwmzw3rbM!};>C@8JA<&6j3+Y9zHUw?tT_-uNh^u@np zM?4qmcc4MZjY1mWLK!>1>7uZ*%Pe%=DV|skj)@OLYvwGXuYBoZvbB{@l}cHK!~UHm z4jV&m&uQAOLsZUYxORkW4|>9t3L@*ieU&b0$sAMH&tKidc%;nb4Z=)D7H<-`#%$^# zi`>amtzJ^^#zB2e%o*wF!gZBqML9>Hq9jqsl-|a}yD&JKsX{Op$7)_=CiZvqj;xN& zqb@L;#4xW$+icPN?@MB|{I!>6U(h!Wxa}14Z0S&y|A5$zbH(DXuE?~WrqNv^;x}vI z0PWfSUuL7Yy``H~*?|%z zT~ZWYq}{X;q*u-}CT;zc_NM|2MKT8)cMy|d>?i^^k)O*}hbEcCrU5Bk{Tjf1>$Q=@ zJ9=R}%vW$~GFV_PuXqE4!6AIuC?Tn~Z=m#Kbj3bUfpb82bxsJ=?2wL>EGp=wsj zAPVwM=CffcycEF; z@kPngVDwPM>T-Bj4##H9VONhbq%=SG;$AjQlV^HOH7!_vZk=}TMt*8qFI}bI=K9g$fgD9$! zO%cK1_+Wbk0Ph}E$BR2}4wO<_b0{qtIA1ll>s*2^!7d2e`Y>$!z54Z4FmZ*vyO}EP z@p&MG_C_?XiKBaP#_XrmRYszF;Hyz#2xqG%yr991pez^qN!~gT_Jc=PPCq^8V(Y9K zz33S+Mzi#$R}ncqe!oJ3>{gacj44kx(SOuC%^9~vT}%7itrC3b;ZPfX;R`D2AlGgN zw$o4-F77!eWU0$?^MhG9zxO@&zDcF;@w2beXEa3SL^htWYY{5k?ywyq7u&)~Nys;@ z8ZNIzUw$#ci&^bZ9mp@A;7y^*XpdWlzy%auO1hU=UfNvfHtiPM@+99# z!uo2`>!*MzphecTjN4x6H)xLeeDVEO#@1oDp`*QsBvmky=JpY@fC0$yIexO%f>c-O zAzUA{ch#N&l;RClb~;`@dqeLPh?e-Mr)T-*?Sr{32|n(}m>4}4c3_H3*U&Yj)grth z{%F0z7YPyjux9hfqa+J|`Y%4gwrZ_TZCQq~0wUR8}9@Jj4lh( z#~%AcbKZ++&f1e^G8LPQ)*Yy?lp5^z4pDTI@b^hlv06?GC%{ZywJcy}3U@zS3|M{M zGPp|cq4Zu~9o_cEZiiNyU*tc73=#Mf>7uzue|6Qo_e!U;oJ)Z$DP~(hOcRy&hR{`J zP7cNIgc)F%E2?p%{%&sxXGDb0yF#zac5fr2x>b)NZz8prv~HBhw^q=R$nZ~@&zdBi z)cEDu+cc1?-;ZLm?^x5Ov#XRhw9{zr;Q#0*wglhWD={Pn$Qm$;z?Vx)_f>igNB!id zmTlMmkp@8kP212#@jq=m%g4ZEl$*a_T;5nHrbt-6D0@eqFP7u+P`;X_Qk68bzwA0h zf{EW5xAV5fD)il-cV&zFmPG|KV4^Z{YJe-g^>uL2l7Ep|NeA2#;k$yerpffdlXY<2 znDODl8(v(24^8Cs3wr(UajK*lY*9yAqcS>92eF=W8<&GtU-}>|S$M5}kyxz~p>-~Pb{(irc?QF~icx8A201&Xin%Hxx@kekd zw>yHjlemC*8(JFz05gs6x7#7EM|xoGtpVVs0szqB0bqwaqAdVG7&rLc6#(=y0YEA! z=jFw}xeKVfmAMI*+}bv7qH=LK2#X5^06wul0s+}M(f|O@&WMyG9frlGyLb z&Eix=47rL84J+tEWcy_XTyc*xw9uOQy`qmHCjAeJ?d=dUhm;P}^F=LH42AEMIh6X8 z*I7Q1jK%gVlL|8w?%##)xSIY`Y+9$SC8!X*_A*S0SWOKNUtza(FZHahoC2|6f=*oD zxJ8-RZk!+YpG+J}Uqnq$y%y>O^@e5M3SSw^29PMwt%8lX^9FT=O@VX$FCLBdlj#<{ zJWWH<#iU!^E7axvK+`u;$*sGq1SmGYc&{g03Md&$r@btQSUIjl&yJXA&=79FdJ+D< z4K^ORdM{M0b2{wRROvjz1@Rb>5dFb@gfkYiIOAKM(NR3*1JpeR_Hk3>WGvU&>}D^HXZ02JUnM z@1s_HhX#rG7;|FkSh2#agJ_2fREo)L`ws+6{?IeWV(>Dy8A(6)IjpSH-n_uO=810y z#4?ez9NnERv6k)N13sXmx)=sv=$$i_QK`hp%I2cyi*J=ihBWZLwpx9Z#|s;+XI!0s zLjYRVt!1KO;mnb7ZL~XoefWU02f{jcY`2wZ4QK+q7gc4iz%d0)5$tPUg~$jVI6vFO zK^wG7t=**T40km@TNUK+WTx<1mL|6Tn6+kB+E$Gpt8SauF9E-CR9Uui_EHn_nmBqS z>o#G}58nHFtICqJPx<_?UZ;z0_(0&UqMnTftMKW@%AxYpa!g0fxGe060^xkRtYguj ze&fPtC!?RgE}FsE0*^2lnE>42K#jp^nJDyzp{JV*jU?{+%KzW37-q|d3i&%eooE6C8Z2t2 z9bBL;^fzVhdLxCQh1+Ms5P)ilz9MYFKdqYN%*u^ch(Fq~QJASr5V_=szAKA4Xm5M} z(Kka%r!noMtz6ZUbjBrJ?Hy&c+mHB{OFQ}=41Irej{0N90`E*~_F1&7Du+zF{Dky) z+KN|-mmIT`Thcij!{3=ibyIn830G zN{kI3d`NgUEJ|2If}J!?@w~FV+v?~tlo8ps3Nl`3^kI)WfZ0|ms6U8HEvD9HIDWkz6`T_QSewYZyzkRh)!g~R>!jaR9;K|#82kfE5^;R!~}H4C?q{1AG?O$5kGp)G$f%VML%aPD?{ zG6)*KodSZRXbl8OD=ETxQLJz)KMI7xjArKUNh3@0f|T|75?Yy=pD7056ja0W)O;Td zCEJ=7q?d|$3rZb+8Cvt6mybV-#1B2}Jai^DOjM2<90tpql|M5tmheg){2NyZR}x3w zL6u}F+C-PIzZ56q0x$;mVJXM1V0;F}y9F29ob51f;;+)t&7l30gloMMHPTuod530FC}j^4#qOJV%5!&e!H9#!N&XQvs5{R zD_FOomd-uk@?_JiWP%&nQ_myBlM6so1Ffa1aaL7B`!ZTXPg_S%TUS*>M^8iJRj1*~ e{{%>Z1YfTk|3C04d;8A^0$7;Zm{b|L#{L(;l>}-4 diff --git a/contentstack/src/main/res/mipmap-xhdpi/ic_launcher.png b/contentstack/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100755 index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4842 zcmZ{oXE5C1x5t0WvTCfdv7&7fy$d2l*k#q|U5FAbL??P!61}%ovaIM)mL!5G(V|6J zAtDH(OY|Du^}l!K&fFLG%sJ2JIp@rG=9y>Ci)Wq~U2RobsvA@Q0MM$dq4lq5{hy#9 zzgp+B{O(-=?1<7r0l>Q?>N6X%s~lmgrmqD6fjj_!c?AF`S0&6U06Z51fWOuNAe#jM z%pSN#J-Mp}`ICpL=qp~?u~Jj$6(~K_%)9}Bn(;pY0&;M00H9x2N23h=CpR7kr8A9X zU%oh4-E@i!Ac}P+&%vOPQ3warO9l!SCN)ixGW54Jsh!`>*aU)#&Mg7;#O_6xd5%I6 zneGSZL3Kn-4B^>#T7pVaIHs3^PY-N^v1!W=%gzfioIWosZ!BN?_M)OOux&6HCyyMf z3ToZ@_h75A33KyC!T)-zYC-bp`@^1n;w3~N+vQ0#4V7!f|JPMlWWJ@+Tg~8>1$GzLlHGuxS)w&NAF*&Y;ef`T^w4HP7GK%6UA8( z{&ALM(%!w2U7WFWwq8v4H3|0cOjdt7$JLh(;U8VcTG;R-vmR7?21nA?@@b+XPgJbD z*Y@v&dTqo5Bcp-dIQQ4@?-m{=7>`LZ{g4jvo$CE&(+7(rp#WShT9&9y>V#ikmXFau03*^{&d(AId0Jg9G;tc7K_{ivzBjqHuJx08cx<8U`z2JjtOK3( zvtuduBHha>D&iu#))5RKXm>(|$m=_;e?7ZveYy=J$3wjL>xPCte-MDcVW<;ng`nf= z9);CVVZjI-&UcSAlhDB{%0v$wPd=w6MBwsVEaV!hw~8G(rs`lw@|#AAHbyA&(I-7Y zFE&1iIGORsaskMqSYfX33U%&17oTszdHPjr&Sx(`IQzoccST*}!cU!ZnJ+~duBM6f z{Lf8PITt%uWZ zTY09Jm5t<2+Un~yC-%DYEP>c-7?=+|reXO4Cd^neCQ{&aP@yODLN8}TQAJ8ogsnkb zM~O>~3&n6d+ee`V_m@$6V`^ltL&?uwt|-afgd7BQ9Kz|g{B@K#qQ#$o4ut`9lQsYfHofccNoqE+`V zQ&UXP{X4=&Z16O_wCk9SFBQPKyu?<&B2zDVhI6%B$12c^SfcRYIIv!s1&r|8;xw5t zF~*-cE@V$vaB;*+91`CiN~1l8w${?~3Uy#c|D{S$I? zb!9y)DbLJ3pZ>!*+j=n@kOLTMr-T2>Hj^I~lml-a26UP1_?#!5S_a&v zeZ86(21wU0)4(h&W0iE*HaDlw+-LngX=}es#X$u*1v9>qR&qUGfADc7yz6$WN`cx9 zzB#!5&F%AK=ed|-eV6kb;R>Atp2Rk=g3lU6(IVEP3!;0YNAmqz=x|-mE&8u5W+zo7 z-QfwS6uzp9K4wC-Te-1~u?zPb{RjjIVoL1bQ=-HK_a_muB>&3I z*{e{sE_sI$CzyK-x>7abBc+uIZf?#e8;K_JtJexgpFEBMq92+Fm0j*DziUMras`o= zTzby8_XjyCYHeE@q&Q_7x?i|V9XY?MnSK;cLV?k>vf?!N87)gFPc9#XB?p)bEWGs$ zH>f$8?U7In{9@vsd%#sY5u!I$)g^%ZyutkNBBJ0eHQeiR5!DlQbYZJ-@09;c?IP7A zx>P=t*xm1rOqr@ec>|ziw@3e$ymK7YSXtafMk30i?>>1lC>LLK1~JV1n6EJUGJT{6 zWP4A(129xkvDP09j<3#1$T6j6$mZaZ@vqUBBM4Pi!H>U8xvy`bkdSNTGVcfkk&y8% z=2nfA@3kEaubZ{1nwTV1gUReza>QX%_d}x&2`jE*6JZN{HZtXSr{{6v6`r47MoA~R zejyMpeYbJ$F4*+?*=Fm7E`S_rUC0v+dHTlj{JnkW-_eRa#9V`9o!8yv_+|lB4*+p1 zUI-t)X$J{RRfSrvh80$OW_Wwp>`4*iBr|oodPt*&A9!SO(x|)UgtVvETLuLZ<-vRp z&zAubgm&J8Pt647V?Qxh;`f6E#Zgx5^2XV($YMV7;Jn2kx6aJn8T>bo?5&;GM4O~| zj>ksV0U}b}wDHW`pgO$L@Hjy2`a)T}s@(0#?y3n zj;yjD76HU&*s!+k5!G4<3{hKah#gBz8HZ6v`bmURyDi(wJ!C7+F%bKnRD4=q{(Fl0 zOp*r}F`6~6HHBtq$afFuXsGAk58!e?O(W$*+3?R|cDO88<$~pg^|GRHN}yml3WkbL zzSH*jmpY=`g#ZX?_XT`>-`INZ#d__BJ)Ho^&ww+h+3>y8Z&T*EI!mtgEqiofJ@5&E z6M6a}b255hCw6SFJ4q(==QN6CUE3GYnfjFNE+x8T(+J!C!?v~Sbh`Sl_0CJ;vvXsP z5oZRiPM-Vz{tK(sJM~GI&VRbBOd0JZmGzqDrr9|?iPT(qD#M*RYb$>gZi*i)xGMD`NbmZt;ky&FR_2+YqpmFb`8b`ry;}D+y&WpUNd%3cfuUsb8 z7)1$Zw?bm@O6J1CY9UMrle_BUM<$pL=YI^DCz~!@p25hE&g62n{j$?UsyYjf#LH~b z_n!l6Z(J9daalVYSlA?%=mfp(!e+Hk%%oh`t%0`F`KR*b-Zb=7SdtDS4`&&S@A)f>bKC7vmRWwT2 zH}k+2Hd7@>jiHwz^GrOeU8Y#h?YK8>a*vJ#s|8-uX_IYp*$9Y=W_Edf%$V4>w;C3h z&>ZDGavV7UA@0QIQV$&?Z_*)vj{Q%z&(IW!b-!MVDGytRb4DJJV)(@WG|MbhwCx!2 z6QJMkl^4ju9ou8Xjb*pv=Hm8DwYsw23wZqQFUI)4wCMjPB6o8yG7@Sn^5%fmaFnfD zSxp8R-L({J{p&cR7)lY+PA9#8Bx87;mB$zXCW8VDh0&g#@Z@lktyArvzgOn&-zerA zVEa9h{EYvWOukwVUGWUB5xr4{nh}a*$v^~OEasKj)~HyP`YqeLUdN~f!r;0dV7uho zX)iSYE&VG67^NbcP5F*SIE@T#=NVjJ1=!Mn!^oeCg1L z?lv_%(ZEe%z*pGM<(UG{eF1T(#PMw}$n0aihzGoJAP^UceQMiBuE8Y`lZ|sF2_h_6 zQw*b*=;2Ey_Flpfgsr4PimZ~8G~R(vU}^Zxmri5)l?N>M_dWyCsjZw<+a zqjmL0l*}PXNGUOh)YxP>;ENiJTd|S^%BARx9D~%7x?F6u4K(Bx0`KK2mianotlX^9 z3z?MW7Coqy^ol0pH)Z3+GwU|Lyuj#7HCrqs#01ZF&KqEg!olHc$O#Wn>Ok_k2`zoD z+LYbxxVMf<(d2OkPIm8Xn>bwFsF6m8@i7PA$sdK~ZA4|ic?k*q2j1YQ>&A zjPO%H@H(h`t+irQqx+e)ll9LGmdvr1zXV;WTi}KCa>K82n90s|K zi`X}C*Vb12p?C-sp5maVDP5{&5$E^k6~BuJ^UxZaM=o+@(LXBWChJUJ|KEckEJTZL zI2K&Nd$U65YoF3_J6+&YU4uKGMq2W6ZQ%BG>4HnIM?V;;Ohes{`Ucs56ue^7@D7;4 z+EsFB)a_(%K6jhxND}n!UBTuF3wfrvll|mp7)3wi&2?LW$+PJ>2)2C-6c@O&lKAn zOm=$x*dn&dI8!QCb(ul|t3oDY^MjHqxl~lp{p@#C%Od-U4y@NQ4=`U!YjK$7b=V}D z%?E40*f8DVrvV2nV>`Z3f5yuz^??$#3qR#q6F($w>kmKK`x21VmX=9kb^+cPdBY2l zGkIZSf%C+`2nj^)j zo}g}v;5{nk<>%xj-2OqDbJ3S`7|tQWqdvJdgiL{1=w0!qS9$A`w9Qm7>N0Y*Ma%P_ zr@fR4>5u{mKwgZ33Xs$RD6(tcVH~Mas-87Fd^6M6iuV^_o$~ql+!eBIw$U)lzl`q9 z=L6zVsZzi0IIW=DT&ES9HajKhb5lz4yQxT-NRBLv_=2sn7WFX&Wp6Y!&}P+%`!A;s zrCwXO3}jrdA7mB`h~N~HT64TM{R$lNj*~ekqSP^n9P~z;P zWPlRPz0h6za8-P>!ARb+A1-r>8VF*xhrGa8W6J$p*wy`ULrD$CmYV7Gt^scLydQWbo7XN-o9X1i7;l+J_8Ncu zc=EX&dg`GRo4==cz2d_Rz28oLS`Suf6OCp~f{0-aQ`t5YZ=!CAMc6-RZw#}A%;s44 znf2`6gcgm=0SezTH9h+JzeR3Lcm;8?*@+?FDfguK^9)z(Z`I!RKrSAI?H~4et6GTkz07Qgq4B6%Q*8Y0yPc4x z8(^YwtZjYIeOvVLey#>@$UzIciJ#x0pJLFg=8UaZv%-&?Yzp7gWNIo_x^(d75=x2c zv|LQ`HrKP(8TqFxTiP5gdT2>aTN0S7XW*pilASS$UkJ2*n+==D)0mgTGxv43t61fr z47GkfMnD-zSH@|mZ26r*d3WEtr+l-xH@L}BM)~ThoMvKqGw=Ifc}BdkL$^wC}=(XSf4YpG;sA9#OSJf)V=rs#Wq$?Wj+nTlu$YXn yn3SQon5>kvtkl(BT2@T#Mvca!|08g9w{vm``2PjZHg=b<1c17-HkzPl9sXa)&-Ts$ diff --git a/contentstack/src/main/res/mipmap-xxhdpi/ic_launcher.png b/contentstack/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100755 index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7718 zcmZ{JWl)?=u?hpbj?h-6mfK3P*Eck~k0Tzeg5-hkABxtZea0_k$f-mlF z0S@Qqtva`>x}TYzc}9LrO?P#qj+P1@HZ?W?0C;Muih9o&|G$cb@ocx1*PEUJ%~tM} z901hB;rx4#{@jOHs_MN00ADr$2n+#$yJuJ64gh!x0KlF(07#?(0ENrf7G3D`0EUHz zisCaq%dJ9dz%zhdRNuG*01nCjDhiPCl@b8xIMfv7^t~4jVRrSTGYyZUWqY@yW=)V_ z&3sUP1SK9v1f{4lDSN(agrKYULc;#EGDVeU*5b@#MOSY5JBn#QG8wqxQh+mdR638{mo5f>O zLUdZIPSjFk0~F26zDrM3y_#P^P91oWtLlPaZrhnM$NR%qsbHHK#?fN?cX?EvAhY1Sr9A(1;Kw4@87~|;2QP~ z(kKOGvCdB}qr4m#)1DwQFlh^NdBZvNLkld&yg%&GU`+boBMsoj5o?8tVuY^b0?4;E zsxoLxz8?S$y~a~x0{?dqk+6~Dd(EG7px_yH(X&NX&qEtHPUhu*JHD258=5$JS12rQ zcN+7p>R>tbFJ3NzEcRIpS98?}YEYxBIA8}1Y8zH9wq0c{hx+EXY&ZQ!-Hvy03X zLTMo4EZwtKfwb294-cY5XhQRxYJSybphcrNJWW2FY+b?|QB^?$5ZN=JlSs9Og(;8+ z*~-#CeeEOxt~F#aWn8wy-N_ilDDe_o+SwJD>4y?j5Lpj z2&!EX)RNxnadPBAa?fOj5D1C{l1E0X?&G3+ckcVfk`?%2FTsoUf4@~eaS#th=zq7v zMEJR@1T?Pi4;$xiPv`3)9rsrbVUH&b0e2{YTEG%;$GGzKUKEim;R6r>F@Q-}9JR-< zOPpQI>W0Vt6&7d?~$d&}chKTr_rELu} zWY;KTvtpJFr?P~ReHL4~2=ABn1`GN4Li%OI_1{mMRQi1Bf?+^Va?xdn4>h)Bq#ZRK zYo%R_h5etrv|!$1QF8fu80fN?1oXe(Jx#e6H^$+>C}N{*i$bNbELsXDA>cxlh|iFq zh~$yJ?1lTdcFd1Yv+Hr^PP!yupP!0H@Y6(wFcaVE+0?qjDJ1;*-Q8qL{NNPc{GAoi z_kBH`kw^(^7ShmzArk^A-!3_$W%!M-pGaZC=K`p-ch&iT%CV0>ofS74aPd7oT&cRr zXI30fVV6#PR*Z?c*orR0!$K6SUl9!H>hG+%`LdifNk`!Sw7Hon{Wn=|qV{a%v9nEq zAdBW*5kq6il=yA}x8cZQt^c+RBS|TRn;!?$ue?@jIV~0w1dt1FJRYI-K5>z-^01)R z)r}A&QXp^?-?}Uj`}ZPqB#}xO-?{0wrmi|eJOEjzdXbey4$rtKNHz)M*o?Ov+;S=K z-l~`)xV`%7Gvzy5wfvwqc0|80K29k0G~1nuBO+y-6)w11Kz2{>yD{HTt-uybe2pe? zUZK*Eij7TT4NwF1Jr@6R7gMuu^@qn#zPIgRtF?-SJL83LBDrh7k#{F^222EXPg}S0d4Lf0!|1 z|2k$^b~)^8$Z-yH{B-vo%7sVU@ZCvXN+Am)-fy$afZ_4HAUpK}j4p`UyXRel-+(VS z#K>-=-oA1pH+Lo$&|!lYB|M7Y&&bF##Oi@y_G3p1X$0I{jS1!NEdTz#x0`H`d*l%X z*8Y3>L*>j@ZQGOdPqwY(GzbA4nxqT(UAP<-tBf{_cb&Hn8hO5gEAotoV;tF6K4~wr2-M0v|2acQ!E@G*g$J z)~&_lvwN%WW>@U_taX5YX@a~pnG7A~jGwQwd4)QKk|^d_x9j+3JYmI5H`a)XMKwDt zk(nmso_I$Kc5m+8iVbIhY<4$34Oz!sg3oZF%UtS(sc6iq3?e8Z;P<{OFU9MACE6y( zeVprnhr!P;oc8pbE%A~S<+NGI2ZT@4A|o9bByQ0er$rYB3(c)7;=)^?$%a${0@70N zuiBVnAMd|qX7BE)8})+FAI&HM|BIb3e=e`b{Do8`J0jc$H>gl$zF26=haG31FDaep zd~i}CHSn$#8|WtE06vcA%1yxiy_TH|RmZ5>pI5*8pJZk0X54JDQQZgIf1Pp3*6hepV_cXe)L2iW$Ov=RZ4T)SP^a_8V} z+Nl?NJL7fAi<)Gt98U+LhE>x4W=bfo4F>5)qBx@^8&5-b>y*Wq19MyS(72ka8XFr2 zf*j(ExtQkjwN|4B?D z7+WzS*h6e_Po+Iqc-2n)gTz|de%FcTd_i9n+Y5*Vb=E{8xj&|h`CcUC*(yeCf~#Mf zzb-_ji&PNcctK6Xhe#gB0skjFFK5C4=k%tQQ}F|ZvEnPcH=#yH4n%z78?McMh!vek zVzwC0*OpmW2*-A6xz0=pE#WdXHMNxSJ*qGY(RoV9)|eu)HSSi_+|)IgT|!7HRx~ zjM$zp%LEBY)1AKKNI?~*>9DE3Y2t5p#jeqeq`1 zsjA-8eQKC*!$%k#=&jm+JG?UD(}M!tI{wD*3FQFt8jgv2xrRUJ}t}rWx2>XWz9ndH*cxl()ZC zoq?di!h6HY$fsglgay7|b6$cUG-f!U4blbj(rpP^1ZhHv@Oi~;BBvrv<+uC;%6QK!nyQ!bb3i3D~cvnpDAo3*3 zXRfZ@$J{FP?jf(NY7~-%Kem>jzZ2+LtbG!9I_fdJdD*;^T9gaiY>d+S$EdQrW9W62 z6w8M&v*8VWD_j)fmt?+bdavPn>oW8djd zRnQ}{XsIlwYWPp;GWLXvbSZ8#w25z1T}!<{_~(dcR_i1U?hyAe+lL*(Y6c;j2q7l! zMeN(nuA8Z9$#w2%ETSLjF{A#kE#WKus+%pal;-wx&tTsmFPOcbJtT?j&i(#-rB}l@ zXz|&%MXjD2YcYCZ3h4)?KnC*X$G%5N)1s!0!Ok!F9KLgV@wxMiFJIVH?E5JcwAnZF zU8ZPDJ_U_l81@&npI5WS7Y@_gf3vTXa;511h_(@{y1q-O{&bzJ z*8g>?c5=lUH6UfPj3=iuuHf4j?KJPq`x@en2Bp>#zIQjX5(C<9-X4X{a^S znWF1zJ=7rEUwQ&cZgyV4L12f&2^eIc^dGIJP@ToOgrU_Qe=T)utR;W$_2Vb7NiZ+d z$I0I>GFIutqOWiLmT~-Q<(?n5QaatHWj**>L8sxh1*pAkwG>siFMGEZYuZ)E!^Hfs zYBj`sbMQ5MR;6=1^0W*qO*Zthx-svsYqrUbJW)!vTGhWKGEu8c+=Yc%xi}Rncu3ph zTT1j_>={i3l#~$!rW!%ZtD9e6l6k-k8l{2w53!mmROAD^2yB^e)3f9_Qyf&C#zk`( z|5RL%r&}#t(;vF4nO&n}`iZpIL=p9tYtYv3%r@GzLWJ6%y_D(icSF^swYM`e8-n43iwo$C~>G<)dd0ze@5}n(!^YD zHf#OVbQ$Li@J}-qcOYn_iWF=_%)EXhrVuaYiai|B<1tXwNsow(m;XfL6^x~|Tr%L3~cs0@c) zDvOFU-AYn1!A;RBM0S}*EhYK49H$mBAxus)CB*KW(87#!#_C0wDr<0*dZ+GN&(3wR z6)cFLiDvOfs*-7Q75ekTAx)k!dtENUKHbP|2y4=tf*d_BeZ(9kR*m;dVzm&0fkKuD zVw5y9N>pz9C_wR+&Ql&&y{4@2M2?fWx~+>f|F%8E@fIfvSM$Dsk26(UL32oNvTR;M zE?F<7<;;jR4)ChzQaN((foV z)XqautTdMYtv<=oo-3W-t|gN7Q43N~%fnClny|NNcW9bIPPP5KK7_N8g!LB8{mK#! zH$74|$b4TAy@hAZ!;irT2?^B0kZ)7Dc?(7xawRUpO~AmA#}eX9A>+BA7{oDi)LA?F ze&CT`Cu_2=;8CWI)e~I_65cUmMPw5fqY1^6v))pc_TBArvAw_5Y8v0+fFFT`T zHP3&PYi2>CDO=a|@`asXnwe>W80%%<>JPo(DS}IQiBEBaNN0EF6HQ1L2i6GOPMOdN zjf3EMN!E(ceXhpd8~<6;6k<57OFRs;mpFM6VviPN>p3?NxrpNs0>K&nH_s ze)2#HhR9JHPAXf#viTkbc{-5C7U`N!`>J-$T!T6%=xo-)1_WO=+BG{J`iIk%tvxF39rJtK49Kj#ne;WG1JF1h7;~wauZ)nMvmBa2PPfrqREMKWX z@v}$0&+|nJrAAfRY-%?hS4+$B%DNMzBb_=Hl*i%euVLI5Ts~UsBVi(QHyKQ2LMXf` z0W+~Kz7$t#MuN|X2BJ(M=xZDRAyTLhPvC8i&9b=rS-T{k34X}|t+FMqf5gwQirD~N1!kK&^#+#8WvcfENOLA`Mcy@u~ zH10E=t+W=Q;gn}&;`R1D$n(8@Nd6f)9=F%l?A>?2w)H}O4avWOP@7IMVRjQ&aQDb) zzj{)MTY~Nk78>B!^EbpT{&h zy{wTABQlVVQG<4;UHY?;#Je#-E;cF3gVTx520^#XjvTlEX>+s{?KP#Rh@hM6R;~DE zaQY16$Axm5ycukte}4FtY-VZHc>=Ps8mJDLx3mwVvcF<^`Y6)v5tF`RMXhW1kE-;! z7~tpIQvz5a6~q-8@hTfF9`J;$QGQN%+VF#`>F4K3>h!tFU^L2jEagQ5Pk1U_I5&B> z+i<8EMFGFO$f7Z?pzI(jT0QkKnV)gw=j74h4*jfkk3UsUT5PemxD`pO^Y#~;P2Cte zzZ^pr>SQHC-576SI{p&FRy36<`&{Iej&&A&%>3-L{h(fUbGnb)*b&eaXj>i>gzllk zLXjw`pp#|yQIQ@;?mS=O-1Tj+ZLzy+aqr7%QwWl?j=*6dw5&4}>!wXqh&j%NuF{1q zzx$OXeWiAue+g#nkqQ#Uej@Zu;D+@z^VU*&HuNqqEm?V~(Z%7D`W5KSy^e|yF6kM7 z8Z9fEpcs^ElF9Vnolfs7^4b0fsNt+i?LwUX8Cv|iJeR|GOiFV!JyHdq+XQ&dER(KSqMxW{=M)lA?Exe&ZEB~6SmHg`zkcD7x#myq0h61+zhLr_NzEIjX zr~NGX_Uh~gdcrvjGI(&5K_zaEf}1t*)v3uT>~Gi$r^}R;H+0FEE5El{y;&DniH2@A z@!71_8mFHt1#V8MVsIYn={v&*0;3SWf4M$yLB^BdewOxz;Q=+gakk`S{_R_t!z2b| z+0d^C?G&7U6$_-W9@eR6SH%+qLx_Tf&Gu5%pn*mOGU0~kv~^K zhPeqYZMWWoA(Y+4GgQo9nNe6S#MZnyce_na@78ZnpwFenVafZC3N2lc5Jk-@V`{|l zhaF`zAL)+($xq8mFm{7fXtHru+DANoGz-A^1*@lTnE;1?03lz8kAnD{zQU=Pb^3f` zT5-g`z5|%qOa!WTBed-8`#AQ~wb9TrUZKU)H*O7!LtNnEd!r8!Oda)u!Gb5P`9(`b z`lMP6CLh4OzvXC#CR|@uo$EcHAyGr=)LB7)>=s3 zvU;aR#cN3<5&CLMFU@keW^R-Tqyf4fdkOnwI(H$x#@I1D6#dkUo@YW#7MU0@=NV-4 zEh2K?O@+2e{qW^7r?B~QTO)j}>hR$q9*n$8M(4+DOZ00WXFonLlk^;os8*zI>YG#? z9oq$CD~byz>;`--_NMy|iJRALZ#+qV8OXn=AmL^GL&|q1Qw-^*#~;WNNNbk(96Tnw zGjjscNyIyM2CYwiJ2l-}u_7mUGcvM+puPF^F89eIBx27&$|p_NG)fOaafGv|_b9G$;1LzZ-1aIE?*R6kHg}dy%~K(Q5S2O6086 z{lN&8;0>!pq^f*Jlh=J%Rmaoed<=uf@$iKl+bieC83IT!09J&IF)9H)C?d!eW1UQ}BQwxaqQY47DpOk@`zZ zo>#SM@oI^|nrWm~Ol7=r`!Bp9lQNbBCeHcfN&X$kjj0R(@?f$OHHt|fWe6jDrYg3(mdEd$8P2Yzjt9*EM zLE|cp-Tzsdyt(dvLhU8}_IX&I?B=|yoZ!&<`9&H5PtApt=VUIB4l0a1NH v0SQqt3DM`an1p};^>=lX|A*k@Y-MNT^ZzF}9G-1G696?OEyXH%^Pv9$0dR%J diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1c3af5cd..baff06ff 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Dec 13 11:19:51 IST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index 8d4ecc08..5e16304c 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -2,7 +2,7 @@ apply plugin: 'maven-publish' apply plugin: 'signing' -task androidSourcesJar(type: Jar) { +tasks.register('androidSourcesJar', Jar) { archiveClassifier.set('sources') if (project.plugins.findPlugin("com.android.library")) { // For Android libraries diff --git a/talismanrc b/talismanrc new file mode 100644 index 00000000..afb4a066 --- /dev/null +++ b/talismanrc @@ -0,0 +1 @@ +threshold: medium \ No newline at end of file From 6117e0377373883373995f23e634425d9dd048a8 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 26 Apr 2023 20:30:38 +0530 Subject: [PATCH 02/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- contentstack/src/main/AndroidManifest.xml | 26 +++++++++---------- .../com/contentstack/sdk/AssetLibrary.java | 12 +++++++-- .../contentstack/sdk/ConnectionStatus.java | 3 --- .../main/java/com/contentstack/sdk/Stack.java | 6 ++--- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/contentstack/src/main/AndroidManifest.xml b/contentstack/src/main/AndroidManifest.xml index 15c759bf..dd44442a 100755 --- a/contentstack/src/main/AndroidManifest.xml +++ b/contentstack/src/main/AndroidManifest.xml @@ -7,19 +7,19 @@ - - - - - - - - - - - - - + + + + + + + diff --git a/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java b/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java index a029629f..e74a88c0 100644 --- a/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java +++ b/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java @@ -17,6 +17,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; /** * AssetLibrary class to fetch all files details on Conentstack server. @@ -352,6 +353,7 @@ private void throwException(String tag, String messageString, Exception e) { } if (e != null) { error.setErrorMessage(e.getLocalizedMessage()); + assert messageString != null; Log.d(tag, messageString); } } @@ -434,17 +436,23 @@ public AssetLibrary includeFallback() { try { urlQueries.put("include_fallback", true); } catch (JSONException e) { - Log.d("AssetLibrary", e.getLocalizedMessage()); + Log.d("AssetLibrary", Objects.requireNonNull(e.getLocalizedMessage())); throwException("AssetLibrary", null, e); } return this; } + + /** + * Include metadata asset response. + * + * @return the asset library + */ public AssetLibrary includeMetadata() { try { urlQueries.put("include_metadata", true); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } return this; } diff --git a/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java b/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java index 8b9aa1ed..f0582be8 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java +++ b/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java @@ -20,7 +20,6 @@ public class ConnectionStatus extends BroadcastReceiver { public ConnectionStatus() { - } @Override @@ -37,9 +36,7 @@ public void onReceive(Context context, Intent intent) { JSONObject jsonObj = null; JSONObject headerObject = null; HashMap headerGroup = new HashMap(); - CSAppConstants.isNetworkAvailable = true; - File offlineCallsFolder = new File(context.getDir("OfflineCalls", 0).getPath()); if (offlineCallsFolder.isDirectory()) { diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index 40796a0b..0293bc5d 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -536,7 +536,7 @@ public void syncPublishType(PublishType type, SyncResultCallBack syncCallBack) { try { syncParams = new JSONObject(); syncParams.put("init", true); - syncParams.put("type", type); + syncParams.put("type", type.toString().toLowerCase()); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -576,7 +576,7 @@ public void sync(String contentType, Date fromDate, Language language, PublishTy syncParams.put("init", true); syncParams.put("start_from", startFromDate); syncParams.put("content_type_uid", contentType); - syncParams.put("type", type); + syncParams.put("type", type.toString().toLowerCase()); syncParams.put("locale", this.localeCode); } catch (JSONException e) { Log.e(TAG, e.getLocalizedMessage()); @@ -591,7 +591,7 @@ public void sync(String contentType, Date fromDate, String locale, PublishType t syncParams.put("init", true); syncParams.put("start_from", startFromDate); syncParams.put("content_type_uid", contentType); - syncParams.put("type", type); + syncParams.put("type", type.toString().toLowerCase()); syncParams.put("locale", locale); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); From 5c2a59cc136ed635d51c99065416f5fc583e14f5 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Thu, 27 Apr 2023 17:15:56 +0530 Subject: [PATCH 03/17] feat:[CS-37836]/region-azure-eu-include-metadata - Added support for include metadata in asset, entry and query class - Added support of Region for Azure-EU - General code and API document improvements - Breaking changes : PublishType Enums are updated to all CAPS - Kotlin support removed due to build issue --- CHANGELOG.md | 115 ++++++----- contentstack/build.gradle | 5 + .../sdk/AssetInstrumentedTest.java | 114 +++++++++-- .../main/java/com/contentstack/sdk/Asset.java | 100 ++++------ .../com/contentstack/sdk/AssetLibrary.java | 32 ++- .../contentstack/sdk/CSBackgroundTask.java | 32 ++- .../contentstack/sdk/CSConnectionRequest.java | 32 ++- .../contentstack/sdk/CSHttpConnection.java | 40 ++-- .../ContentstackUtil.java => CSUtil.java} | 4 +- .../java/com/contentstack/sdk/ClearCache.java | 6 +- .../contentstack/sdk/ConnectionStatus.java | 43 ++-- .../com/contentstack/sdk/ContentType.java | 12 +- .../com/contentstack/sdk/Contentstack.java | 87 ++++---- .../com/contentstack/sdk/EntriesModel.java | 4 +- .../main/java/com/contentstack/sdk/Entry.java | 70 +++---- .../java/com/contentstack/sdk/EntryModel.java | 4 +- .../main/java/com/contentstack/sdk/Group.java | 16 +- .../com/contentstack/sdk/IURLRequestHTTP.java | 6 +- .../main/java/com/contentstack/sdk/Query.java | 188 +++++++++--------- .../com/contentstack/sdk/QueryResult.java | 4 +- .../CSAppConstants.java => SDKConstant.java} | 8 +- .../com/contentstack/sdk/SDKController.java | 44 ++++ .../CSAppUtils.java => SDKUtil.java} | 8 +- .../main/java/com/contentstack/sdk/Stack.java | 47 +---- .../java/com/contentstack/sdk/SyncStack.java | 4 +- .../sdk/utilities/CSController.java | 21 -- .../java/com/contentstack/sdk/AssetTest.java | 24 +++ 27 files changed, 567 insertions(+), 503 deletions(-) rename contentstack/src/main/java/com/contentstack/sdk/{utilities/ContentstackUtil.java => CSUtil.java} (98%) rename contentstack/src/main/java/com/contentstack/sdk/{utilities/CSAppConstants.java => SDKConstant.java} (96%) create mode 100755 contentstack/src/main/java/com/contentstack/sdk/SDKController.java rename contentstack/src/main/java/com/contentstack/sdk/{utilities/CSAppUtils.java => SDKUtil.java} (98%) delete mode 100755 contentstack/src/main/java/com/contentstack/sdk/utilities/CSController.java create mode 100644 contentstack/src/test/java/com/contentstack/sdk/AssetTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 992967b9..8bd572ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # CHANGELOG +## Version 3.12.0 + +### Date: 02-May-2023 + +- Added support for include metadata in asset, entry and query class +- Added support of Region for Azure-EU +- General code and API document improvements +- Breaking changes : PublishType Enums are updated to all CAPS +- Kotlin support removed due to build issue + +--- + ## Version 3.11.0 ### Date: 08-Feb-2023 @@ -131,15 +143,8 @@ Below two support from the Config class has been removed permanently Change: - Removed support for unsafe (HTTP) request. -- Below two breaking changes from Config class has been deprecated - -```java -@Deprecated -public void setSSL(boolean isSSL)setSSL() - -@Deprecated -public boolean isSSL() -``` +- Deprecated setSSL(boolean isSSL)setSSL() from config class +- Deprecated isSSL() from config class --- @@ -172,11 +177,11 @@ Added below function support for sync in Stack class New Features: - Entry - - added method ‘addParam’ + - added method ‘addParam’ - Query - - added method 'addParam' + - added method 'addParam' - Asset - - added method ‘addParam' + - added method ‘addParam' --- @@ -187,21 +192,21 @@ New Features: New Features: - Stack - - added method 'ImageTransform' + - added method 'ImageTransform' - Query - - added method 'includeContentType' + - added method 'includeContentType' - QueryResult - - added method 'content_type' + - added method 'content_type' - API Modifications: - - None + - None API deprecation: - Query - - Deprecated method 'includeSchema' + - Deprecated method 'includeSchema' - Bug Fixes: - - None + - None --- @@ -210,18 +215,18 @@ API deprecation: ### Date: 28-July-2017 - New Features: - - None + - None - API Modifications: - - None + - None API deprecation: None - Bug Fixes: - - Cache Policy bug fixed. - - Cache Policy timeout increased. + - Cache Policy bug fixed. + - Cache Policy timeout increased. --- @@ -234,15 +239,18 @@ New Features: - None API Modifications: - - None + +- None API deprecation: - - Asset + +- Asset 1] Removed getPublishDetails() method. Entry 1] Removed getPublishDetails() method. Bug Fixes: - - None. + +- None. --- @@ -251,10 +259,12 @@ Bug Fixes: ### Date: 17-May-2017 New Features: - - None + +- None API Modifications: - - None + +- None API deprecation: @@ -275,16 +285,16 @@ New Features: Added new class Group Entry - 1] Added getAllEntries(String refKey, String refContentType) method. - 2] Added getGroups(String key) method. - 3] Added getGroup(String key) method. +1] Added getAllEntries(String refKey, String refContentType) method. +2] Added getGroups(String key) method. +3] Added getGroup(String key) method. Asset - 1] Added setCachePolicy(CachePolicy policy) method. - 2] Added getTags() method. +1] Added setCachePolicy(CachePolicy policy) method. +2] Added getTags() method. AssetLibrary - 1] Added setCachePolicy(CachePolicy policy) method. +1] Added setCachePolicy(CachePolicy policy) method. API Modifications: @@ -320,7 +330,7 @@ environment, Config config) method. Stack 1] Added asset() method. 2] Added assetLibrary() method. Entry - 1] Added getPublishDetails() method. +1] Added getPublishDetails() method. API Modifications: @@ -332,20 +342,20 @@ Conetntstack 1] Removed stack(Context context, String stackApiKey, String access environment, boolean isEnvironmentUid) method. Stack - 1] Removed setVersion(String version) method. - 2] Removed setURL(String hostName, boolean isSSL) method. - 3] Removed setEnvironment(String environment, boolean isEnvironmentUid) method. - 4] Removed isEnvironmentUid() method. - 5] Removed getEnvironment() method. - 6] Removed getVersion() method. - 7] Removed getURL() method +1] Removed setVersion(String version) method. +2] Removed setURL(String hostName, boolean isSSL) method. +3] Removed setEnvironment(String environment, boolean isEnvironmentUid) method. +4] Removed isEnvironmentUid() method. +5] Removed getEnvironment() method. +6] Removed getVersion() method. +7] Removed getURL() method Entry - 1] Removed getMetadata() method. +1] Removed getMetadata() method. Query - 1] Removed afterUid() method. - 2] Removed beforeUid() method. +1] Removed afterUid() method. +2] Removed beforeUid() method. Bug Fixes: @@ -379,17 +389,20 @@ Fixed API calls issue for Android 7.0 Nougat. ### Date: 22-September-2016 New Features: - - None -API Modifications: - - None + +- None + API Modifications: +- None API deprecation: - - None + +- None Bug Fixes: - - Query 1] Fixed search method issue causing improper result. - - Entry 1] Fixed includeReference method issue causing improper result. 2] Fixed fetch method which -now return response as per environment. + +- Query 1] Fixed search method issue causing improper result. +- Entry 1] Fixed includeReference method issue causing improper result. 2] Fixed fetch method which + now return response as per environment. --- diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 281a8a17..f38e31e9 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -80,5 +80,10 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.android.volley:volley:1.2.1' testImplementation 'junit:junit:5.9.2' + testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + androidTestImplementation ("androidx.test.espresso:espresso-contrib:3.5.1") { + exclude module: "protobuf-lite" + } } \ No newline at end of file diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java index 105b13ed..cf4f4467 100644 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java @@ -6,16 +6,20 @@ import android.content.Context; import android.util.Log; +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; import androidx.test.platform.app.InstrumentationRegistry; import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.junit.runners.MethodSorters; import java.util.List; +@RunWith(AndroidJUnit4ClassRunner.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class AssetInstrumentedTest { @@ -37,15 +41,13 @@ public static void oneTimeSetUp() throws Exception { @Test() - public void test_A_getAllAssetsToSetAssetUID() { + public void testAGetAllAssetsToSetAssetUid() { final AssetLibrary assetLibrary = stack.assetLibrary(); assetLibrary.fetchAll(new FetchAssetsCallback() { @Override public void onCompletion(ResponseType responseType, List assets, Error error) { if (error == null) { - Log.d(TAG, "response: " + assets.get(0).getAssetUid()); assetUid = assets.get(0).getAssetUid(); - Log.e(assetUid, assetUid); } } }); @@ -164,18 +166,100 @@ public void onCompletion(ResponseType responseType, Error error) { }); } + @Test + public void setStackInstance() { + } + + @Test + public void configure() { + } + + @Test + public void setHeader() { + } + + @Test + public void removeHeader() { + } + + @Test + public void setUid() { + } + + @Test + public void getAssetUid() { + } + + @Test + public void getFileType() { + } + + @Test + public void getFileSize() { + } + + @Test + public void getFileName() { + } + + @Test + public void getUrl() { + } + + @Test + public void toJSON() { + } + + @Test + public void getCreateAt() { + } -// @Test -// public void test_AZURE_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.AZURE_NA); -// Context appContext = ApplicationProvider.getApplicationContext(); -// stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); -// } + @Test + public void getCreatedBy() { + } + + @Test + public void getUpdateAt() { + } + + @Test + public void getUpdatedBy() { + } + + @Test + public void getDeleteAt() { + } + + @Test + public void getDeletedBy() { + } + + @Test + public void getTags() { + } + + @Test + public void setCachePolicy() { + } + + @Test + public void fetch() { + } + + @Test + public void setTags() { + } + + @Test + public void addParam() { + } + + @Test + public void includeDimension() { + } + + @Test + public void includeFallback() { + } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/Asset.java b/contentstack/src/main/java/com/contentstack/sdk/Asset.java index 66446fad..2e273363 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Asset.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Asset.java @@ -4,11 +4,6 @@ import android.util.ArrayMap; import android.util.Log; -import com.contentstack.sdk.utilities.CSAppConstants; -import com.contentstack.sdk.utilities.CSAppUtils; -import com.contentstack.sdk.utilities.CSController; -import com.contentstack.sdk.utilities.ContentstackUtil; - import org.json.JSONException; import org.json.JSONObject; @@ -17,15 +12,16 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Objects; /** - * Asset class to fetch files details on Conentstack server. + * Asset class to fetch files details on Contentstack server. * * @author contentstack.com */ public class Asset { - private final static String TAG = "Asset"; + private final static String TAG = Asset.class.getSimpleName(); protected String assetUid = null; protected String contentType = null; protected String fileSize = null; @@ -34,28 +30,26 @@ public class Asset { protected JSONObject json = null; protected String[] tagsArray = null; JSONObject urlQueries = new JSONObject(); - protected ArrayMap headerGroup_app; - protected ArrayMap headerGroup_local; + protected ArrayMap headerGroupApp; + protected ArrayMap headerGroupLocal; protected Stack stackInstance; private CachePolicy cachePolicyForCall = CachePolicy.IGNORE_CACHE; - - private final long maxCacheTimeForCall = 0; - private final long defaultCacheTimeInterval = 0; + private final long MAX_CACHE_TIME_FOR_CALL = 0; protected Asset() { - this.headerGroup_local = new ArrayMap<>(); - this.headerGroup_app = new ArrayMap<>(); + this.headerGroupLocal = new ArrayMap<>(); + this.headerGroupApp = new ArrayMap<>(); } protected Asset(String assetUid) { this.assetUid = assetUid; - this.headerGroup_local = new ArrayMap<>(); - this.headerGroup_app = new ArrayMap<>(); + this.headerGroupLocal = new ArrayMap<>(); + this.headerGroupApp = new ArrayMap<>(); } protected void setStackInstance(Stack stack) { this.stackInstance = stack; - this.headerGroup_app = stack.localHeader; + this.headerGroupApp = stack.localHeader; } /** @@ -64,22 +58,21 @@ protected void setStackInstance(Stack stack) { * * @param jsonObject json object of particular file attached in the built object.
*

- * {@link Asset} can be generate using of data filled {@link Entry} and {@link #configure(JSONObject)}.
- * + * {@link Asset} can be generate using of data filled {@link Entry} + * and {@link #configure(JSONObject)}.
*

Example :
*
1. Single Attachment :-
*

      *                   assetObject.configure(entryObject.getJSONObject(attached_image_field_uid));
- * - *
2. Multiple Attachment :-
+ *
2. Multiple Attachment : *

*

      *                   for (int i = 0; i < array.length(); i++) {
* Asset assetObject = stack.asset("assetUid");
- * assetObject.configure(entryObject.getJSONObject(attached_image_field_uid));
+ * assetObject.configure(entryObject.getJSONObject(attached_image_field_uid)); * }
*
* @return {@link Asset} instance. @@ -118,7 +111,7 @@ public void setHeader(String key, String value) { if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) { removeHeader(key); - headerGroup_local.put(key, value); + headerGroupLocal.put(key, value); } } @@ -136,12 +129,9 @@ public void setHeader(String key, String value) { * */ public void removeHeader(String key) { - if (headerGroup_local != null) { - + if (headerGroupLocal != null) { if (!TextUtils.isEmpty(key)) { - if (headerGroup_local.containsKey(key)) { - headerGroup_local.remove(key); - } + headerGroupLocal.remove(key); } } } @@ -253,9 +243,9 @@ public Calendar getCreateAt() { try { String value = json.optString("created_at"); - return ContentstackUtil.parseDate(value, null); + return CSUtil.parseDate(value, null); } catch (Exception e) { - CSAppUtils.showLog(TAG, e.getLocalizedMessage()); + SDKUtil.showLog(TAG, e.getLocalizedMessage()); } return null; } @@ -286,9 +276,9 @@ public Calendar getUpdateAt() { try { String value = json.optString("updated_at"); - return ContentstackUtil.parseDate(value, null); + return CSUtil.parseDate(value, null); } catch (Exception e) { - CSAppUtils.showLog(TAG, e.getLocalizedMessage()); + SDKUtil.showLog(TAG, e.getLocalizedMessage()); } return null; } @@ -319,9 +309,9 @@ public Calendar getDeleteAt() { try { String value = json.optString("deleted_at"); - return ContentstackUtil.parseDate(value, null); + return CSUtil.parseDate(value, null); } catch (Exception e) { - CSAppUtils.showLog(TAG, e.getLocalizedMessage()); + SDKUtil.showLog(TAG, e.getLocalizedMessage()); } return null; } @@ -392,18 +382,16 @@ public void setCachePolicy(CachePolicy cachePolicy) { public void fetch(FetchResultCallback callback) { try { String urlEndpoint = "/" + stackInstance.VERSION + "/assets/" + assetUid; - ArrayMap headers = getHeader(headerGroup_local); + ArrayMap headers = getHeader(headerGroupLocal); if (headers.containsKey("environment")) { urlQueries.put("environment", headers.get("environment")); } String mainStringForMD5 = urlEndpoint + new JSONObject().toString() + headers.toString(); - String md5Value = new CSAppUtils().getMD5FromString(mainStringForMD5.trim()); - File cacheFile = new File(CSAppConstants.cacheFolderName + File.separator + md5Value); + String md5Value = new SDKUtil().getMD5FromString(mainStringForMD5.trim()); + File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + md5Value); switch (cachePolicyForCall) { case IGNORE_CACHE: - fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); - break; case NETWORK_ONLY: fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); break; @@ -413,7 +401,7 @@ public void fetch(FetchResultCallback callback) { case CACHE_ELSE_NETWORK: if (cacheFile.exists()) { boolean needToSendCall = false; - needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); + needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) MAX_CACHE_TIME_FOR_CALL); if (needToSendCall) { fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); } else { @@ -431,7 +419,7 @@ public void fetch(FetchResultCallback callback) { break; case NETWORK_ELSE_CACHE: - if (CSAppConstants.isNetworkAvailable) { + if (SDKConstant.isNetworkAvailable) { fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); } else { fetchFromCache(cacheFile, callback); @@ -441,7 +429,7 @@ public void fetch(FetchResultCallback callback) { } catch (Exception e) { Error error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_JsonNotProper); + error.setErrorMessage(SDKConstant.ErrorMessage_JsonNotProper); callback.onRequestFail(ResponseType.UNKNOWN, error); } } @@ -449,7 +437,7 @@ public void fetch(FetchResultCallback callback) { private void fetchFromNetwork(String URL, JSONObject urlQueries, ArrayMap headers, String cacheFilePath, FetchResultCallback callback) { if (callback != null) { HashMap urlParams = getUrlParams(urlQueries); - new CSBackgroundTask(this, stackInstance, CSController.FETCHASSETS, URL, headers, urlParams, new JSONObject(), cacheFilePath, CSAppConstants.callController.ASSET.toString(), false, CSAppConstants.RequestMethod.GET, callback); + new CSBackgroundTask(this, stackInstance, SDKController.GET_ASSETS, URL, headers, urlParams, new JSONObject(), cacheFilePath, SDKConstant.callController.ASSET.toString(), false, SDKConstant.RequestMethod.GET, callback); } } @@ -458,16 +446,16 @@ private void fetchFromCache(File cacheFile, FetchResultCallback callback) { Error error = null; if (cacheFile.exists()) { boolean needToSendCall = false; - needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); + needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) MAX_CACHE_TIME_FOR_CALL); if (needToSendCall) { error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); } else { setCacheModel(cacheFile, callback); } } else { error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); } if (callback != null && error != null) { @@ -478,7 +466,7 @@ private void fetchFromCache(File cacheFile, FetchResultCallback callback) { //Asset modeling from cache. private void setCacheModel(File cacheFile, FetchResultCallback callback) { - AssetModel model = new AssetModel(CSAppUtils.getJsonFromCacheFile(cacheFile), false, true); + AssetModel model = new AssetModel(SDKUtil.getJsonFromCacheFile(cacheFile), false, true); this.contentType = model.contentType; this.fileSize = model.fileSize; @@ -514,14 +502,14 @@ protected Asset setTags(String[] tags) { private HashMap getUrlParams(JSONObject urlQueriesJSON) { HashMap hashMap = new HashMap<>(); if (urlQueriesJSON != null && urlQueriesJSON.length() > 0) { - Iterator iter = urlQueriesJSON.keys(); - while (iter.hasNext()) { - String key = iter.next(); + Iterator iterator = urlQueriesJSON.keys(); + while (iterator.hasNext()) { + String key = iterator.next(); try { Object value = urlQueriesJSON.opt(key); hashMap.put(key, value); } catch (Exception e) { - CSAppUtils.showLog(TAG, "setQueryJson" + e.getLocalizedMessage()); + SDKUtil.showLog(TAG, "setQueryJson" + e.getLocalizedMessage()); } } return hashMap; @@ -530,7 +518,7 @@ private HashMap getUrlParams(JSONObject urlQueriesJSON) { } private ArrayMap getHeader(ArrayMap localHeader) { - ArrayMap mainHeader = headerGroup_app; + ArrayMap mainHeader = headerGroupApp; ArrayMap classHeaders = new ArrayMap<>(); if (localHeader != null && localHeader.size() > 0) { if (mainHeader != null && mainHeader.size() > 0) { @@ -549,7 +537,7 @@ private ArrayMap getHeader(ArrayMap localHeader) return localHeader; } } else { - return headerGroup_app; + return headerGroupApp; } } @@ -582,7 +570,7 @@ public Asset addParam(String key, String value) { try { urlQueries.put(key, value); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } } return this; @@ -599,7 +587,7 @@ public Asset includeDimension() { try { urlQueries.put("include_dimension", true); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } return this; } @@ -620,7 +608,7 @@ public Asset includeFallback() { try { urlQueries.put("include_fallback", true); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } return this; } diff --git a/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java b/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java index e74a88c0..042a6d44 100644 --- a/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java +++ b/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java @@ -4,10 +4,6 @@ import android.util.ArrayMap; import android.util.Log; -import com.contentstack.sdk.utilities.CSAppConstants; -import com.contentstack.sdk.utilities.CSAppUtils; -import com.contentstack.sdk.utilities.CSController; - import org.json.JSONException; import org.json.JSONObject; @@ -120,7 +116,7 @@ public AssetLibrary sort(String key, ORDERBY orderby) { break; } } catch (Exception e) { - throwException("sort", CSAppConstants.ErrorMessage_QueryFilterException, e); + throwException("sort", SDKConstant.ErrorMessage_QueryFilterException, e); } return this; @@ -141,7 +137,7 @@ public AssetLibrary includeCount() { try { urlQueries.put("include_count", "true"); } catch (Exception e) { - throwException("includeCount", CSAppConstants.ErrorMessage_QueryFilterException, e); + throwException("includeCount", SDKConstant.ErrorMessage_QueryFilterException, e); } return this; } @@ -161,7 +157,7 @@ public AssetLibrary includeRelativeUrl() { try { urlQueries.put("relative_urls", "true"); } catch (Exception e) { - throwException("relative_urls", CSAppConstants.ErrorMessage_QueryFilterException, e); + throwException("relative_urls", SDKConstant.ErrorMessage_QueryFilterException, e); } return this; } @@ -219,8 +215,8 @@ public void fetchAll(FetchAssetsCallback assetsCallback) { urlQueries.put("environment", headers.get("environment")); } String mainStringForMD5 = URL + new JSONObject().toString() + headers.toString(); - String md5Value = new CSAppUtils().getMD5FromString(mainStringForMD5.trim()); - File cacheFile = new File(CSAppConstants.cacheFolderName + File.separator + md5Value); + String md5Value = new SDKUtil().getMD5FromString(mainStringForMD5.trim()); + File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + md5Value); switch (cachePolicyForCall) { case IGNORE_CACHE: fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), assetsCallback); @@ -234,7 +230,7 @@ public void fetchAll(FetchAssetsCallback assetsCallback) { case CACHE_ELSE_NETWORK: if (cacheFile.exists()) { boolean needToSendCall = false; - needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); + needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); if (needToSendCall) { fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), assetsCallback); } else { @@ -251,7 +247,7 @@ public void fetchAll(FetchAssetsCallback assetsCallback) { fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), assetsCallback); break; case NETWORK_ELSE_CACHE: - if (CSAppConstants.isNetworkAvailable) { + if (SDKConstant.isNetworkAvailable) { fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), assetsCallback); } else { fetchFromCache(cacheFile, assetsCallback); @@ -260,14 +256,14 @@ public void fetchAll(FetchAssetsCallback assetsCallback) { } } catch (Exception e) { - CSAppUtils.showLog(TAG, e.toString()); + SDKUtil.showLog(TAG, e.toString()); } } private void fetchFromNetwork(String URL, JSONObject urlQueries, ArrayMap headers, String cacheFilePath, FetchAssetsCallback callback) { if (callback != null) { HashMap urlParams = getUrlParams(urlQueries); - new CSBackgroundTask(this, stackInstance, CSController.FETCHALLASSETS, URL, headers, urlParams, new JSONObject(), cacheFilePath, CSAppConstants.callController.ASSETLIBRARY.toString(), false, CSAppConstants.RequestMethod.GET, assetsCallback); + new CSBackgroundTask(this, stackInstance, SDKController.GET_ALL_ASSETS, URL, headers, urlParams, new JSONObject(), cacheFilePath, SDKConstant.callController.ASSET_LIBRARY.toString(), false, SDKConstant.RequestMethod.GET, assetsCallback); } } @@ -275,16 +271,16 @@ private void fetchFromCache(File cacheFile, FetchAssetsCallback callback) { Error error = null; if (cacheFile.exists()) { boolean needToSendCall = false; - needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); + needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); if (needToSendCall) { error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); } else { setCacheModel(cacheFile, callback); } } else { error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); } if (callback != null && error != null) { @@ -295,7 +291,7 @@ private void fetchFromCache(File cacheFile, FetchAssetsCallback callback) { //Asset modeling from cache. private void setCacheModel(File cacheFile, FetchAssetsCallback callback) { - AssetsModel assetsModel = new AssetsModel(CSAppUtils.getJsonFromCacheFile(cacheFile), true); + AssetsModel assetsModel = new AssetsModel(SDKUtil.getJsonFromCacheFile(cacheFile), true); List objectList = assetsModel.objects; assetsModel = null; count = objectList.size(); @@ -335,7 +331,7 @@ private HashMap getUrlParams(JSONObject urlQueriesJSON) { Object value = urlQueriesJSON.opt(key); hashMap.put(key, value); } catch (Exception e) { - CSAppUtils.showLog(TAG, e.toString()); + SDKUtil.showLog(TAG, e.toString()); } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java b/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java index 13931de5..ca5fa04c 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java @@ -2,8 +2,6 @@ import android.util.ArrayMap; -import com.contentstack.sdk.utilities.CSAppConstants; - import org.json.JSONObject; import java.util.HashMap; @@ -13,9 +11,9 @@ */ class CSBackgroundTask { - public CSBackgroundTask(Query queryInstance, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, CSAppConstants.RequestMethod method, ResultCallBack callback) { + public CSBackgroundTask(Query queryInstance, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, SDKConstant.RequestMethod method, ResultCallBack callback) { - if (CSAppConstants.isNetworkAvailable) { + if (SDKConstant.isNetworkAvailable) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -33,8 +31,8 @@ public CSBackgroundTask(Query queryInstance, Stack stackInstance, String control } } - public CSBackgroundTask(Entry entryInstance, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean isOffline, CSAppConstants.RequestMethod method, ResultCallBack callBack) { - if (CSAppConstants.isNetworkAvailable) { + public CSBackgroundTask(Entry entryInstance, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean isOffline, SDKConstant.RequestMethod method, ResultCallBack callBack) { + if (SDKConstant.isNetworkAvailable) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -51,8 +49,8 @@ public CSBackgroundTask(Entry entryInstance, Stack stackInstance, String control } } - public CSBackgroundTask(AssetLibrary assetLibrary, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean isOffline, CSAppConstants.RequestMethod method, ResultCallBack callback) { - if (CSAppConstants.isNetworkAvailable) { + public CSBackgroundTask(AssetLibrary assetLibrary, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean isOffline, SDKConstant.RequestMethod method, ResultCallBack callback) { + if (SDKConstant.isNetworkAvailable) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -69,8 +67,8 @@ public CSBackgroundTask(AssetLibrary assetLibrary, Stack stackInstance, String c } } - public CSBackgroundTask(Asset asset, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean isOffline, CSAppConstants.RequestMethod method, ResultCallBack callback) { - if (CSAppConstants.isNetworkAvailable) { + public CSBackgroundTask(Asset asset, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean isOffline, SDKConstant.RequestMethod method, ResultCallBack callback) { + if (SDKConstant.isNetworkAvailable) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -88,9 +86,9 @@ public CSBackgroundTask(Asset asset, Stack stackInstance, String controller, Str } - public CSBackgroundTask(Stack stack, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlParams, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean b, CSAppConstants.RequestMethod method, ResultCallBack callback) { + public CSBackgroundTask(Stack stack, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlParams, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean b, SDKConstant.RequestMethod method, ResultCallBack callback) { - if (CSAppConstants.isNetworkAvailable) { + if (SDKConstant.isNetworkAvailable) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -109,9 +107,9 @@ public CSBackgroundTask(Stack stack, Stack stackInstance, String controller, Str } - public CSBackgroundTask(ContentType contentType, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlParams, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean b, CSAppConstants.RequestMethod method, ResultCallBack callback) { + public CSBackgroundTask(ContentType contentType, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlParams, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean b, SDKConstant.RequestMethod method, ResultCallBack callback) { - if (CSAppConstants.isNetworkAvailable) { + if (SDKConstant.isNetworkAvailable) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -132,8 +130,8 @@ public CSBackgroundTask(ContentType contentType, Stack stackInstance, String con private void sendErrorToUser(ResultCallBack callbackObject) { Error error = new Error(); - error.setErrorCode(CSAppConstants.NONETWORKCONNECTION); - error.setErrorMessage(CSAppConstants.ErrorMessage_NoNetwork); + error.setErrorCode(SDKConstant.NONETWORKCONNECTION); + error.setErrorMessage(SDKConstant.ErrorMessage_NoNetwork); if (callbackObject != null) { callbackObject.onRequestFail(ResponseType.UNKNOWN, error); } @@ -141,7 +139,7 @@ private void sendErrorToUser(ResultCallBack callbackObject) { private void sendErrorForHeader(ResultCallBack callbackObject) { Error error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_CalledDefaultMethod); + error.setErrorMessage(SDKConstant.ErrorMessage_CalledDefaultMethod); if (callbackObject != null) { callbackObject.onRequestFail(ResponseType.UNKNOWN, error); } diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java b/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java index 9a61476d..b11b5a3b 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java @@ -3,10 +3,6 @@ import android.util.ArrayMap; -import com.contentstack.sdk.utilities.CSAppConstants; -import com.contentstack.sdk.utilities.CSAppUtils; -import com.contentstack.sdk.utilities.CSController; - import org.json.JSONObject; import java.io.File; @@ -27,7 +23,7 @@ class CSConnectionRequest implements IRequestModelHTTP { private static final String TAG = "CSConnectionRequest"; private String urlToCall; - private CSAppConstants.RequestMethod method; + private SDKConstant.RequestMethod method; private String controller; private JSONObject paramsJSON; private ArrayMap header; @@ -88,10 +84,10 @@ public void setContentTypeInstance(ContentType contentTypeInstance) { } public void setParams(Object... objects) { - CSAppUtils.showLog(TAG, "ParallelTasks------|" + objects[0] + " started"); + SDKUtil.showLog(TAG, "ParallelTasks------|" + objects[0] + " started"); this.urlToCall = (String) objects[0]; - this.method = (CSAppConstants.RequestMethod) objects[1]; + this.method = (SDKConstant.RequestMethod) objects[1]; this.controller = (String) objects[2]; paramsJSON = (JSONObject) objects[3]; this.header = (ArrayMap) objects[4]; @@ -164,11 +160,11 @@ public void onRequestFailed(JSONObject error, int statusCode, ResultCallBack cal } } catch (Exception e) { - CSAppUtils.showLog(TAG, "------------------catch 210 urlReq---|" + e); + SDKUtil.showLog(TAG, "------------------catch 210 urlReq---|" + e); errorMessage = e.getLocalizedMessage(); } if (errorMessage == null || (!(errorMessage.length() > 0))) { - errorMessage = CSAppConstants.ErrorMessage_Default; + errorMessage = SDKConstant.ErrorMessage_Default; } errorObject.setErrorCode(errorCode); errorObject.setErrorMessage(errorMessage); @@ -190,21 +186,21 @@ public void onRequestFinished(CSHttpConnection request) { createFileIntoCacheDir(responseJSON); } - if (controller.equalsIgnoreCase(CSController.QUERYOBJECT)) { + if (controller.equalsIgnoreCase(SDKController.GET_QUERY_ENTRIES)) { EntriesModel model = new EntriesModel(responseJSON, null, false); notifyClass.getResult(model.formName, null); notifyClass.getResultObject(model.objectList, responseJSON, false); model = null; - } else if (controller.equalsIgnoreCase(CSController.SINGLEQUERYOBJECT)) { + } else if (controller.equalsIgnoreCase(SDKController.SINGLE_QUERY_ENTRIES)) { EntriesModel model = new EntriesModel(responseJSON, null, false); notifyClass.getResult(model.formName, null); notifyClass.getResultObject(model.objectList, responseJSON, true); model = null; - } else if (controller.equalsIgnoreCase(CSController.FETCHENTRY)) { + } else if (controller.equalsIgnoreCase(SDKController.GET_ENTRY)) { EntryModel model = new EntryModel(responseJSON, null, false, false, false); entryInstance.resultJson = model.jsonObject; @@ -227,14 +223,14 @@ public void onRequestFinished(CSHttpConnection request) { ((EntryResultCallBack) request.getCallBackObject()).onRequestFinish(ResponseType.NETWORK); } - } else if (controller.equalsIgnoreCase(CSController.FETCHALLASSETS)) { + } else if (controller.equalsIgnoreCase(SDKController.GET_ALL_ASSETS)) { AssetsModel assetsModel = new AssetsModel(responseJSON, false); List objectList = assetsModel.objects; assetsModel = null; assetLibrary.getResultObject(objectList, responseJSON, false); - } else if (controller.equalsIgnoreCase(CSController.FETCHASSETS)) { + } else if (controller.equalsIgnoreCase(SDKController.GET_ASSETS)) { AssetModel model = new AssetModel(responseJSON, false, false); assetInstance.contentType = model.contentType; @@ -249,7 +245,7 @@ public void onRequestFinished(CSHttpConnection request) { if (request.getCallBackObject() != null) { ((FetchResultCallback) request.getCallBackObject()).onRequestFinish(ResponseType.NETWORK); } - } else if (controller.equalsIgnoreCase(CSController.FETCHSYNC)) { + } else if (controller.equalsIgnoreCase(SDKController.GET_SYNC)) { SyncStack model = new SyncStack(); model.setJSON(responseJSON); @@ -257,7 +253,7 @@ public void onRequestFinished(CSHttpConnection request) { ((SyncResultCallBack) request.getCallBackObject()).onRequestFinish(model); } - } else if (controller.equalsIgnoreCase(CSController.FETCHCONTENTTYPES)) { + } else if (controller.equalsIgnoreCase(SDKController.GET_CONTENT_TYPES)) { ContentTypesModel model = new ContentTypesModel(); model.setJSON(responseJSON); @@ -309,14 +305,14 @@ protected void createFileIntoCacheDir(Object jsonObject) { file.close(); } catch (Exception e) { Error error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_SavingNetworkCallResponseForCache); + error.setErrorMessage(SDKConstant.ErrorMessage_SavingNetworkCallResponseForCache); HashMap hashMap = new HashMap(); hashMap.put("error", e.getLocalizedMessage()); error.setErrors(hashMap); if (callBackObject != null) { callBackObject.onRequestFail(ResponseType.CACHE, error); } - CSAppUtils.showLog(TAG, e.getLocalizedMessage()); + SDKUtil.showLog(TAG, e.getLocalizedMessage()); } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java index 694ce706..08dc6f70 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java @@ -8,8 +8,6 @@ import com.android.volley.Request; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; -import com.contentstack.sdk.utilities.CSAppConstants; -import com.contentstack.sdk.utilities.CSAppUtils; import org.json.JSONArray; import org.json.JSONObject; @@ -34,7 +32,7 @@ class CSHttpConnection implements IURLRequestHTTP { private JSONObject requestJSON; private final IRequestModelHTTP connectionRequest; private ResultCallBack callBackObject; - private CSAppConstants.RequestMethod requestMethod; + private SDKConstant.RequestMethod requestMethod; private JSONObject responseJSON; public HashMap getFormParams() { @@ -110,12 +108,12 @@ public boolean getTreatDuplicateKeysAsArrayItems() { } @Override - public void setRequestMethod(CSAppConstants.RequestMethod requestMethod) { + public void setRequestMethod(SDKConstant.RequestMethod requestMethod) { this.requestMethod = requestMethod; } @Override - public CSAppConstants.RequestMethod getRequestMethod() { + public SDKConstant.RequestMethod getRequestMethod() { return requestMethod; } @@ -129,7 +127,7 @@ public String setFormParamsGET(HashMap params) { if (params != null && params.size() > 0) { String urlParams = null; - urlParams = info.equalsIgnoreCase(CSAppConstants.callController.QUERY.name()) || info.equalsIgnoreCase(CSAppConstants.callController.ENTRY.name()) ? getParams(params) : null; + urlParams = info.equalsIgnoreCase(SDKConstant.callController.QUERY.name()) || info.equalsIgnoreCase(SDKConstant.callController.ENTRY.name()) ? getParams(params) : null; if (TextUtils.isEmpty(urlParams)) { for (Map.Entry e : params.entrySet()) { @@ -213,7 +211,7 @@ private String getParams(HashMap params) { } } catch (Exception e1) { - CSAppUtils.showLog(TAG, "--------------------getQueryParam--||" + e1.toString()); + SDKUtil.showLog(TAG, "--------------------getQueryParam--||" + e1.toString()); } } @@ -224,12 +222,12 @@ private String getParams(HashMap params) { @Override public void send() { String url = null; - String protocol = CSAppConstants.URLSCHEMA_HTTPS; + String protocol = SDKConstant.URLSCHEMA_HTTPS; int requestId = getRequestId(requestMethod); final HashMap headers = new HashMap<>(); int count = this.headers.size(); - if (requestMethod == CSAppConstants.RequestMethod.GET) { + if (requestMethod == SDKConstant.RequestMethod.GET) { String params = setFormParamsGET(formParams); if (params != null) { url = urlPath + params; @@ -246,7 +244,7 @@ public void send() { } headers.put("Content-Type", "application/json"); headers.put("User-Agent", defaultUserAgent()); - headers.put("X-User-Agent", "contentstack-android/" + CSAppConstants.SDK_VERSION); + headers.put("X-User-Agent", "contentstack-android/" + SDKConstant.SDK_VERSION); jsonObjectRequest = new JSONUTF8Request(requestId, url, requestJSON, response -> { responseJSON = response; Log.i("response", response.toString()); @@ -262,7 +260,7 @@ public Map getHeaders() { }; - jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(CSAppConstants.TimeOutDuration, CSAppConstants.NumRetry, CSAppConstants.BackOFMultiplier)); + jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(SDKConstant.TimeOutDuration, SDKConstant.NumRetry, SDKConstant.BackOFMultiplier)); jsonObjectRequest.setShouldCache(false); Contentstack.addToRequestQueue(protocol, jsonObjectRequest, info); } @@ -276,7 +274,7 @@ private void httpRequest(String url) { } }, this::generateBuiltError); - jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(CSAppConstants.TimeOutDuration, CSAppConstants.NumRetry, CSAppConstants.BackOFMultiplier)); + jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(SDKConstant.TimeOutDuration, SDKConstant.NumRetry, SDKConstant.BackOFMultiplier)); jsonObjectRequest.setShouldCache(false); Contentstack.addToRequestQueue("https://", jsonObjectRequest, info); } @@ -286,7 +284,7 @@ private String defaultUserAgent() { return agent != null ? agent : ("Android" + System.getProperty("java.version")); } - private int getRequestId(CSAppConstants.RequestMethod requestMethod) { + private int getRequestId(SDKConstant.RequestMethod requestMethod) { switch (requestMethod) { case GET: return 0; @@ -305,7 +303,7 @@ private void generateBuiltError(VolleyError error) { try { int statusCode = 0; responseJSON = new JSONObject(); - responseJSON.put("error_message", CSAppConstants.ErrorMessage_Default); + responseJSON.put("error_message", SDKConstant.ErrorMessage_Default); if (error != null) { @@ -318,27 +316,27 @@ private void generateBuiltError(VolleyError error) { } else { if (error.toString().equalsIgnoreCase("NoConnectionError")) { - responseJSON.put("error_message", CSAppConstants.ErrorMessage_VolleyNoConnectionError); + responseJSON.put("error_message", SDKConstant.ErrorMessage_VolleyNoConnectionError); } else if (error.toString().equalsIgnoreCase("AuthFailureError")) { - responseJSON.put("error_message", CSAppConstants.ErrorMessage_VolleyAuthFailureError); + responseJSON.put("error_message", SDKConstant.ErrorMessage_VolleyAuthFailureError); } else if (error.toString().equalsIgnoreCase("NetworkError")) { - responseJSON.put("error_message", CSAppConstants.ErrorMessage_NoNetwork); + responseJSON.put("error_message", SDKConstant.ErrorMessage_NoNetwork); } else if (error.toString().equalsIgnoreCase("ParseError")) { - responseJSON.put("error_message", CSAppConstants.ErrorMessage_VolleyParseError); + responseJSON.put("error_message", SDKConstant.ErrorMessage_VolleyParseError); } else if (error.toString().equalsIgnoreCase("ServerError")) { - responseJSON.put("error_message", CSAppConstants.ErrorMessage_VolleyServerError); + responseJSON.put("error_message", SDKConstant.ErrorMessage_VolleyServerError); } else if (error.toString().equalsIgnoreCase("TimeoutError")) { - responseJSON.put("error_message", CSAppConstants.ErrorMessage_VolleyServerError); + responseJSON.put("error_message", SDKConstant.ErrorMessage_VolleyServerError); } else { if (error.getMessage() != null) { @@ -360,7 +358,7 @@ private void generateBuiltError(VolleyError error) { connectionRequest.onRequestFailed(responseJSON, 0, callBackObject); } } catch (Exception exception) { - CSAppUtils.showLog(TAG, exception.toString()); + SDKUtil.showLog(TAG, exception.toString()); } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/utilities/ContentstackUtil.java b/contentstack/src/main/java/com/contentstack/sdk/CSUtil.java similarity index 98% rename from contentstack/src/main/java/com/contentstack/sdk/utilities/ContentstackUtil.java rename to contentstack/src/main/java/com/contentstack/sdk/CSUtil.java index 38367bad..5ea25180 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/utilities/ContentstackUtil.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSUtil.java @@ -1,4 +1,4 @@ -package com.contentstack.sdk.utilities; +package com.contentstack.sdk; import android.annotation.SuppressLint; @@ -14,7 +14,7 @@ * * @author contentstack.com, Inc */ -public class ContentstackUtil { +public class CSUtil { /** * Converts the given date to user's timezone. diff --git a/contentstack/src/main/java/com/contentstack/sdk/ClearCache.java b/contentstack/src/main/java/com/contentstack/sdk/ClearCache.java index bdb48d5b..9d26fb30 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/ClearCache.java +++ b/contentstack/src/main/java/com/contentstack/sdk/ClearCache.java @@ -4,8 +4,6 @@ import android.content.Context; import android.content.Intent; -import com.contentstack.sdk.utilities.CSAppUtils; - import org.json.JSONObject; import java.io.File; @@ -43,7 +41,7 @@ public void onReceive(Context context, Intent intent) { } else { if (file.exists()) { - JSONObject jsonObj = CSAppUtils.getJsonFromCacheFile(file); + JSONObject jsonObj = SDKUtil.getJsonFromCacheFile(file); if (jsonObj != null) { if (jsonObj.optString("timestamp") != null) { long responseTime = Long.parseLong(jsonObj.optString("timestamp")); @@ -59,7 +57,7 @@ public void onReceive(Context context, Intent intent) { } } } else { - CSAppUtils.showLog("ClearCache", "--------------------no offline network calls"); + SDKUtil.showLog("ClearCache", "--------------------no offline network calls"); } } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java b/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java index f0582be8..18a844f9 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java +++ b/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java @@ -1,24 +1,29 @@ package com.contentstack.sdk; +import static com.contentstack.sdk.SDKConstant.*; + import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import com.contentstack.sdk.utilities.CSAppConstants; -import com.contentstack.sdk.utilities.CSAppUtils; - import org.json.JSONObject; import java.io.File; import java.util.HashMap; +import java.util.Objects; /** * Connection Status. * - * @author contentstack.com, Inc + * @author ishaileshmishra */ public class ConnectionStatus extends BroadcastReceiver { + private final String TAG = ConnectionStatus.class.getSimpleName(); + + /** + * Instantiates a new Connection status. + */ public ConnectionStatus() { } @@ -27,36 +32,37 @@ public void onReceive(Context context, Intent intent) { Contentstack.isNetworkAvailable(context); - if (!CSAppConstants.isNetworkAvailable) { + if (!isNetworkAvailable) { //no net connection - CSAppConstants.isNetworkAvailable = false; - + isNetworkAvailable = false; } else { try { JSONObject jsonObj = null; JSONObject headerObject = null; - HashMap headerGroup = new HashMap(); - CSAppConstants.isNetworkAvailable = true; + HashMap headerGroup = new HashMap<>(); + isNetworkAvailable = true; File offlineCallsFolder = new File(context.getDir("OfflineCalls", 0).getPath()); if (offlineCallsFolder.isDirectory()) { File[] childFiles = offlineCallsFolder.listFiles(); + assert childFiles != null; for (File child : childFiles) { File file = new File(offlineCallsFolder, child.getName()); if (file.exists()) { - jsonObj = CSAppUtils.getJsonFromCacheFile(file); + jsonObj = SDKUtil.getJsonFromCacheFile(file); if (jsonObj != null) { headerObject = jsonObj.optJSONObject("headers"); - int count = headerObject.names().length(); + assert headerObject != null; + int count = Objects.requireNonNull(headerObject.names()).length(); for (int i = 0; i < count; i++) { - String key = headerObject.names().getString(i); + String key = Objects.requireNonNull(headerObject.names()).getString(i); headerGroup.put(key, headerObject.optString(key)); } CSConnectionRequest connectionRequest = new CSConnectionRequest(); connectionRequest.setParams( - jsonObj.opt("url").toString(), - CSAppConstants.RequestMethod.POST, - jsonObj.opt("controller").toString(), + Objects.requireNonNull(jsonObj.opt("url")).toString(), + RequestMethod.POST, + Objects.requireNonNull(jsonObj.opt("controller")).toString(), jsonObj.optJSONObject("params"), headerGroup, jsonObj.opt("cacheFileName"), @@ -66,17 +72,14 @@ public void onReceive(Context context, Intent intent) { } child.delete(); } else { - CSAppUtils.showLog("ConnectionStatus", "--------------------no offline network calls"); + SDKUtil.showLog(TAG, "No offline network calls"); } } } } catch (Exception e) { - CSAppUtils.showLog("ConnectionStatus", "-----content stack----------send saved network calls-------catch|" + e); + SDKUtil.showLog(TAG, "contentstack send saved network calls-------catch|" + e); } } - - CSAppUtils.showLog("ConnectionStatus", "---------------------BuiltAppConstants.isNetworkAvailable|" + CSAppConstants.isNetworkAvailable); - } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/ContentType.java b/contentstack/src/main/java/com/contentstack/sdk/ContentType.java index 193efe2e..5dfe8598 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/ContentType.java +++ b/contentstack/src/main/java/com/contentstack/sdk/ContentType.java @@ -3,10 +3,6 @@ import android.util.ArrayMap; import android.text.TextUtils; -import com.contentstack.sdk.utilities.CSAppConstants; -import com.contentstack.sdk.utilities.CSAppUtils; -import com.contentstack.sdk.utilities.CSController; - import org.json.JSONObject; import java.util.HashMap; @@ -185,7 +181,7 @@ public void fetch(JSONObject params, final ContentTypesCallback callback) { fetchContentTypes(URL, params, headers, null, callback); } else { Error error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_JsonNotProper); + error.setErrorMessage(SDKConstant.ErrorMessage_JsonNotProper); callback.onRequestFail(ResponseType.UNKNOWN, error); } @@ -193,7 +189,7 @@ public void fetch(JSONObject params, final ContentTypesCallback callback) { } catch (Exception e) { Error error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_JsonNotProper); + error.setErrorMessage(SDKConstant.ErrorMessage_JsonNotProper); callback.onRequestFail(ResponseType.UNKNOWN, error); } @@ -205,7 +201,7 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap if (callback != null) { HashMap urlParams = getUrlParams(urlQueries); - new CSBackgroundTask(this, stackInstance, CSController.FETCHCONTENTTYPES, urlString, headers, urlParams, new JSONObject(), cacheFilePath, CSAppConstants.callController.CONTENTTYPES.toString(), false, CSAppConstants.RequestMethod.GET, callback); + new CSBackgroundTask(this, stackInstance, SDKController.GET_CONTENT_TYPES, urlString, headers, urlParams, new JSONObject(), cacheFilePath, SDKConstant.callController.CONTENT_TYPES.toString(), false, SDKConstant.RequestMethod.GET, callback); } } @@ -222,7 +218,7 @@ private HashMap getUrlParams(JSONObject urlQueriesJSON) { Object value = urlQueriesJSON.opt(key); hashMap.put(key, value); } catch (Exception e) { - CSAppUtils.showLog(TAG, "------setQueryJson" + e.toString()); + SDKUtil.showLog(TAG, "------setQueryJson" + e.toString()); } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java index e110c9ca..bbaa1595 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java @@ -12,15 +12,13 @@ import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.toolbox.Volley; -import com.contentstack.sdk.utilities.CSAppConstants; -import com.contentstack.sdk.utilities.CSAppUtils; import java.io.File; /** - * Contains all Contentstack API classes and functions. + * Contains all Contentstack SDK classes and functions. * - * @author contentstack.com, Inc + * @author ishaileshmishra */ public class Contentstack { @@ -43,37 +41,36 @@ public Contentstack(Context applicationContext) { *
* You can find your stack api key from web. * - * @param context application context. - * @param stackApiKey application api Key of your application on Contentstack. - * @param accessToken access token - * @param environment environment name + * @param context application context. + * @param apiKey The api Key of your stack on Contentstack. + * @param deliveryToken The Delivery Token for the stack + * @param environment environment name * @return {@link Stack} instance. * - * *

Example :
*
      * Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "stag");
      * 
*/ - public static Stack stack(Context context, String stackApiKey, String accessToken, String environment) throws Exception { + public static Stack stack(Context context, String apiKey, String deliveryToken, String environment) throws Exception { if (context != null) { - if (!TextUtils.isEmpty(stackApiKey)) { - if (!TextUtils.isEmpty(accessToken)) { + if (!TextUtils.isEmpty(apiKey)) { + if (!TextUtils.isEmpty(deliveryToken)) { if (!TextUtils.isEmpty(environment)) { Config config = new Config(); config.setEnvironment(environment); - return initializeStack(context, stackApiKey, accessToken, config); + return initializeStack(context, apiKey, deliveryToken, config); } else { - throw new Exception(CSAppConstants.ErrorMessage_Stack_Environment_IsNull); + throw new Exception(SDKConstant.ErrorMessage_Stack_Environment_IsNull); } } else { - throw new Exception(CSAppConstants.ErrorMessage_Stack_AccessToken_IsNull); + throw new Exception(SDKConstant.ErrorMessage_Stack_AccessToken_IsNull); } } else { - throw new Exception(CSAppConstants.ErrorMessage_StackApiKeyIsNull); + throw new Exception(SDKConstant.ErrorMessage_StackApiKeyIsNull); } } else { - throw new Exception(CSAppConstants.ErrorMessage_StackContextIsNull); + throw new Exception(SDKConstant.ErrorMessage_StackContextIsNull); } } @@ -83,26 +80,22 @@ public static Stack stack(Context context, String stackApiKey, String accessToke *
* You can find your stack api key from web. * - * @param context application context. - * @param stackApiKey application api Key of your application on Contentstack. - * @param accessToken access token - * @param config {@link Config} instance to set environment and other configuration details. + * @param context application context. + * @param apiKey The api Key of your stack on Contentstack. + * @param deliveryToken The delivery token for the stack on Contentstack + * @param config {@link Config} instance to set environment and other configuration details. * @return {@link Stack} instance. * - * *

Example :
*
      * Config config = new Config();
      * config.setEnvironment("stag");
-     * Stack stack = Contentstack.stack(context, "apiKey", "delierytoken", config);
+     * Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", config);
      */
-
-
-    public static Stack stack(Context context, String stackApiKey, String accessToken,
-                              String environment, Config config) throws Exception {
+    public static Stack stack(Context context, String apiKey, String deliveryToken, String environment, Config config) throws Exception {
         if (context != null) {
-            if (!TextUtils.isEmpty(stackApiKey)) {
-                if (!TextUtils.isEmpty(accessToken)) {
+            if (!TextUtils.isEmpty(apiKey)) {
+                if (!TextUtils.isEmpty(deliveryToken)) {
                     if (!TextUtils.isEmpty(environment)) {
 
                         if (config != null) {
@@ -111,36 +104,35 @@ public static Stack stack(Context context, String stackApiKey, String accessToke
                             config = new Config();
                             config.setEnvironment(environment);
                         }
-                        return initializeStack(context, stackApiKey, accessToken, config);
+                        return initializeStack(context, apiKey, deliveryToken, config);
                     } else {
-                        throw new Exception(CSAppConstants.ErrorMessage_Stack_Environment_IsNull);
+                        throw new Exception(SDKConstant.ErrorMessage_Stack_Environment_IsNull);
                     }
                 } else {
-                    throw new Exception(CSAppConstants.ErrorMessage_Stack_AccessToken_IsNull);
+                    throw new Exception(SDKConstant.ErrorMessage_Stack_AccessToken_IsNull);
                 }
             } else {
-                throw new Exception(CSAppConstants.ErrorMessage_StackApiKeyIsNull);
+                throw new Exception(SDKConstant.ErrorMessage_StackApiKeyIsNull);
             }
         } else {
-            throw new Exception(CSAppConstants.ErrorMessage_StackContextIsNull);
+            throw new Exception(SDKConstant.ErrorMessage_StackContextIsNull);
         }
     }
 
 
-    private static Stack initializeStack(Context mContext, String stackApiKey, String accessToken, Config config) {
-        Stack stack = new Stack(stackApiKey.trim());
-        stack.setHeader("api_key", stackApiKey);
-        stack.setHeader("access_token", accessToken);
-        context = mContext;
+    private static Stack initializeStack(Context appContext, String apiKey, String deliveryToken, Config config) {
+        Stack stack = new Stack(apiKey.trim());
+        stack.setHeader("api_key", apiKey);
+        stack.setHeader("access_token", deliveryToken);
+        context = appContext;
         stack.setConfig(config);
-
         if (context != null) {
             try {
                 File queryCacheFile = context.getDir("ContentstackCache", 0);
-                CSAppConstants.cacheFolderName = queryCacheFile.getPath();
+                SDKConstant.cacheFolderName = queryCacheFile.getPath();
                 clearCache(context);
             } catch (Exception e) {
-                CSAppUtils.showLog(TAG, "Contentstack-" + e.getLocalizedMessage());
+                SDKUtil.showLog(TAG, "Contentstack-" + e.getLocalizedMessage());
             }
         }
         return stack;
@@ -163,8 +155,6 @@ public static synchronized Contentstack getInstance(Context context) {
 
     public RequestQueue getRequestQueue() {
         if (requestQueue == null) {
-            // getApplicationContext() is key, it keeps you from leaking the
-            // Activity or BroadcastReceiver if someone passes one in.
             requestQueue = Volley.newRequestQueue(context);
         }
         return requestQueue;
@@ -182,7 +172,6 @@ protected static RequestQueue getRequestQueue(String protocol) {
     }
 
     protected static  void addToRequestQueue(String protocol, Request req, String tag) {
-        // set the default tag if tag is empty
         req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
         getRequestQueue(protocol).add(req);
     }
@@ -200,8 +189,7 @@ private static void clearCache(Context context) {
         if (android.os.Build.VERSION.SDK_INT >= 23) flag = PendingIntent.FLAG_IMMUTABLE | flag;
         PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, flag);
         AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
-        alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
-                SystemClock.elapsedRealtime(), AlarmManager.INTERVAL_DAY, pendingIntent);
+        alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), AlarmManager.INTERVAL_DAY, pendingIntent);
     }
 
     /**
@@ -210,9 +198,8 @@ private static void clearCache(Context context) {
     protected static void isNetworkAvailable(Context context) {
         ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
         if (connectivityManager.getNetworkInfo(0) != null || connectivityManager.getNetworkInfo(1).getState() != null) {
-            CSAppConstants.isNetworkAvailable = connectivityManager.getActiveNetworkInfo() != null;
+            SDKConstant.isNetworkAvailable = connectivityManager.getActiveNetworkInfo() != null;
         } else
-            CSAppConstants.isNetworkAvailable = connectivityManager.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED ||
-                    connectivityManager.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED;
+            SDKConstant.isNetworkAvailable = connectivityManager.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED || connectivityManager.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED;
     }
 }
diff --git a/contentstack/src/main/java/com/contentstack/sdk/EntriesModel.java b/contentstack/src/main/java/com/contentstack/sdk/EntriesModel.java
index 5b8007dc..3d278591 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/EntriesModel.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/EntriesModel.java
@@ -1,7 +1,5 @@
 package com.contentstack.sdk;
 
-import com.contentstack.sdk.utilities.CSAppUtils;
-
 import org.json.JSONArray;
 import org.json.JSONObject;
 
@@ -37,7 +35,7 @@ protected EntriesModel(JSONObject responseJSON, String formName, boolean isFromC
                 }
             }
         } catch (Exception localException) {
-            CSAppUtils.showLog("EntriesModel", "Parsing Error" + localException);
+            SDKUtil.showLog("EntriesModel", "Parsing Error" + localException);
         }
 
     }
diff --git a/contentstack/src/main/java/com/contentstack/sdk/Entry.java b/contentstack/src/main/java/com/contentstack/sdk/Entry.java
index 5d90f028..aae22364 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/Entry.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/Entry.java
@@ -4,10 +4,6 @@
 import android.util.ArrayMap;
 import android.util.Log;
 
-import com.contentstack.sdk.utilities.CSAppConstants;
-import com.contentstack.sdk.utilities.CSAppUtils;
-import com.contentstack.sdk.utilities.CSController;
-import com.contentstack.sdk.utilities.ContentstackUtil;
 import com.contentstack.txtmark.Configuration;
 import com.contentstack.txtmark.Processor;
 
@@ -315,7 +311,7 @@ public Object get(String key) {
                 return null;
             }
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, e.getLocalizedMessage());
             return null;
         }
     }
@@ -335,7 +331,7 @@ public String getHtmlText(String markdownKey) {
         try {
             return Processor.process(getString(markdownKey), Configuration.builder().forceExtentedProfile().build());
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, e.getLocalizedMessage());
             return null;
         }
     }
@@ -360,7 +356,7 @@ public ArrayList getMultipleHtmlText(String markdownKey) {
             }
             return multipleHtmlStrings;
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, e.getLocalizedMessage());
             return null;
         }
     }
@@ -569,9 +565,9 @@ public Calendar getDate(String key) {
 
         try {
             String value = getString(key);
-            return ContentstackUtil.parseDate(value, null);
+            return CSUtil.parseDate(value, null);
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, e.getLocalizedMessage());
         }
         return null;
     }
@@ -589,9 +585,9 @@ public Calendar getCreateAt() {
 
         try {
             String value = getString("created_at");
-            return ContentstackUtil.parseDate(value, null);
+            return CSUtil.parseDate(value, null);
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, e.getLocalizedMessage());
         }
         return null;
     }
@@ -622,9 +618,9 @@ public Calendar getUpdateAt() {
 
         try {
             String value = getString("updated_at");
-            return ContentstackUtil.parseDate(value, null);
+            return CSUtil.parseDate(value, null);
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, e.getLocalizedMessage());
         }
         return null;
     }
@@ -654,9 +650,9 @@ public Calendar getDeleteAt() {
 
         try {
             String value = getString("deleted_at");
-            return ContentstackUtil.parseDate(value, null);
+            return CSUtil.parseDate(value, null);
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, e.getLocalizedMessage());
         }
         return null;
     }
@@ -813,7 +809,7 @@ public ArrayList getAllEntries(String refKey, String refContentType) {
                             entryInstance = contentTypeInstance.stackInstance.contentType(refContentType).entry();
                         } catch (Exception e) {
                             entryInstance = new Entry(refContentType);
-                            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+                            SDKUtil.showLog(TAG, e.getLocalizedMessage());
                         }
                         entryInstance.setUid(model.entryUid);
                         entryInstance.ownerEmailId = model.ownerEmailId;
@@ -833,7 +829,7 @@ public ArrayList getAllEntries(String refKey, String refContentType) {
                 }
             }
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, e.getLocalizedMessage());
             return null;
         }
 
@@ -867,7 +863,7 @@ public Entry except(String[] fieldUid) {
                 }
             }
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, "--except-catch|" + e);
+            SDKUtil.showLog(TAG, "--except-catch|" + e);
         }
         return this;
     }
@@ -897,7 +893,7 @@ public Entry includeReference(String referenceField) {
                 otherPostJSON.put("include[]", referenceArray);
             }
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, "--include Reference-catch|" + e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, "--include Reference-catch|" + e.getLocalizedMessage());
         }
 
         return this;
@@ -929,7 +925,7 @@ public Entry includeReference(String[] referenceFields) {
                 otherPostJSON.put("include[]", referenceArray);
             }
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, "--include Reference-catch|" + e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, "--include Reference-catch|" + e.getLocalizedMessage());
         }
 
         return this;
@@ -961,7 +957,7 @@ public Entry only(String[] fieldUid) {
                 }
             }
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, "--include Reference-catch|" + e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, "--include Reference-catch|" + e.getLocalizedMessage());
         }
 
         return this;
@@ -999,7 +995,7 @@ public Entry onlyWithReferenceUid(ArrayList fieldUid, String referenceFi
                 includeReference(referenceFieldUid);
             }
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, "--onlyWithReferenceUid-catch|" + e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, "--onlyWithReferenceUid-catch|" + e.getLocalizedMessage());
         }
         return this;
     }
@@ -1038,7 +1034,7 @@ public Entry exceptWithReferenceUid(ArrayList fieldUid, String reference
                 includeReference(referenceFieldUid);
             }
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, "--exceptWithReferenceUid-catch|" + e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, "--exceptWithReferenceUid-catch|" + e.getLocalizedMessage());
         }
         return this;
     }
@@ -1091,9 +1087,9 @@ public void fetch(EntryResultCallBack callBack) {
                 }
 
                 String mainStringForMD5 = URL + new JSONObject().toString() + headerAll.toString();
-                String md5Value = new CSAppUtils().getMD5FromString(mainStringForMD5.trim());
+                String md5Value = new SDKUtil().getMD5FromString(mainStringForMD5.trim());
 
-                File cacheFile = new File(CSAppConstants.cacheFolderName + File.separator + md5Value);
+                File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + md5Value);
 
 
                 switch (cachePolicyForCall) {
@@ -1113,7 +1109,7 @@ public void fetch(EntryResultCallBack callBack) {
                     case CACHE_ELSE_NETWORK:
                         if (cacheFile.exists()) {
                             boolean needToSendCall = false;
-                            needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall);
+                            needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall);
                             if (needToSendCall) {
                                 fetchFromNetwork(URL, urlQueries, cacheFile.getPath(), callBack);
                             } else {
@@ -1135,7 +1131,7 @@ public void fetch(EntryResultCallBack callBack) {
 
                     case NETWORK_ELSE_CACHE:
 
-                        if (CSAppConstants.isNetworkAvailable) {
+                        if (SDKConstant.isNetworkAvailable) {
                             fetchFromNetwork(URL, urlQueries, cacheFile.getPath(), callBack);
                         } else {
                             fetchFromCache(cacheFile, callBack);
@@ -1146,7 +1142,7 @@ public void fetch(EntryResultCallBack callBack) {
                 }
 
             } else {
-                throwException(CSAppConstants.ErrorMessage_EntryUID, null, callBack);
+                throwException(SDKConstant.ErrorMessage_EntryUID, null, callBack);
             }
         } catch (Exception e) {
             throwException(null, e, callBack);
@@ -1161,11 +1157,11 @@ private void fetchFromNetwork(String URL, JSONObject urlQueries, String cacheFil
             setIncludeJSON(urlQueries, callBack);
             mainJson.put("query", urlQueries);
 
-            mainJson.put("_method", CSAppConstants.RequestMethod.GET.toString());
+            mainJson.put("_method", SDKConstant.RequestMethod.GET.toString());
 
             HashMap urlParams = getUrlParams(mainJson);
 
-            new CSBackgroundTask(this, contentTypeInstance.stackInstance, CSController.FETCHENTRY, URL, getHeader(localHeader), urlParams, new JSONObject(), cacheFilePath, CSAppConstants.callController.ENTRY.toString(), false, CSAppConstants.RequestMethod.GET, callBack);
+            new CSBackgroundTask(this, contentTypeInstance.stackInstance, SDKController.GET_ENTRY, URL, getHeader(localHeader), urlParams, new JSONObject(), cacheFilePath, SDKConstant.callController.ENTRY.toString(), false, SDKConstant.RequestMethod.GET, callBack);
 
         } catch (Exception e) {
             throwException(null, e, callBack);
@@ -1183,18 +1179,18 @@ private void fetchFromCache(File cacheFile, EntryResultCallBack callback) {
             // } else {
             //     needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) defaultCacheTimeInterval);
             // }
-            needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall);
+            needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall);
 
             if (needToSendCall) {
                 error = new Error();
-                error.setErrorMessage(CSAppConstants.ErrorMessage_EntryNotFoundInCache);
+                error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache);
 
             } else {
                 setCacheModel(cacheFile, callback);
             }
         } else {
             error = new Error();
-            error.setErrorMessage(CSAppConstants.ErrorMessage_EntryNotFoundInCache);
+            error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache);
         }
 
         if (callback != null && error != null) {
@@ -1205,7 +1201,7 @@ private void fetchFromCache(File cacheFile, EntryResultCallBack callback) {
     //Entry modeling from cache.
     private void setCacheModel(File cacheFile, EntryResultCallBack callback) {
 
-        EntryModel model = new EntryModel(CSAppUtils.getJsonFromCacheFile(cacheFile), null, false, true, false);
+        EntryModel model = new EntryModel(SDKUtil.getJsonFromCacheFile(cacheFile), null, false, true, false);
         this.resultJson = model.jsonObject;
         this.ownerEmailId = model.ownerEmailId;
         this.ownerUid = model.ownerUid;
@@ -1237,10 +1233,10 @@ private void setCacheModel(File cacheFile, EntryResultCallBack callback) {
      */
 
     public void cancelRequest() {
-        CSAppConstants.cancelledCallController.add(CSAppConstants.callController.ENTRY.toString());
+        SDKConstant.cancelledCallController.add(SDKConstant.callController.ENTRY.toString());
 
         if (Contentstack.requestQueue != null) {
-            Contentstack.requestQueue.cancelAll(CSAppConstants.callController.ENTRY.toString());
+            Contentstack.requestQueue.cancelAll(SDKConstant.callController.ENTRY.toString());
         }
     }
 
@@ -1274,7 +1270,7 @@ private HashMap getUrlParams(JSONObject jsonMain) {
                     Object value = queryJSON.opt(key);
                     hashMap.put(key, value);
                 } catch (Exception e) {
-                    CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+                    SDKUtil.showLog(TAG, e.getLocalizedMessage());
                 }
             }
 
diff --git a/contentstack/src/main/java/com/contentstack/sdk/EntryModel.java b/contentstack/src/main/java/com/contentstack/sdk/EntryModel.java
index a0b7c729..aaa737ef 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/EntryModel.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/EntryModel.java
@@ -1,7 +1,5 @@
 package com.contentstack.sdk;
 
-import com.contentstack.sdk.utilities.CSAppUtils;
-
 import org.json.JSONArray;
 import org.json.JSONObject;
 
@@ -109,7 +107,7 @@ public EntryModel(JSONObject jsonObj, String entryUid, boolean isFromObjectsMode
 
 
         } catch (Exception e) {
-            CSAppUtils.showLog("EntryModel", e.getLocalizedMessage());
+            SDKUtil.showLog("EntryModel", e.getLocalizedMessage());
         }
 
     }
diff --git a/contentstack/src/main/java/com/contentstack/sdk/Group.java b/contentstack/src/main/java/com/contentstack/sdk/Group.java
index bfe35199..2d27905b 100644
--- a/contentstack/src/main/java/com/contentstack/sdk/Group.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/Group.java
@@ -2,8 +2,6 @@
 
 import android.text.TextUtils;
 
-import com.contentstack.sdk.utilities.CSAppUtils;
-import com.contentstack.sdk.utilities.ContentstackUtil;
 import com.contentstack.txtmark.Configuration;
 import com.contentstack.txtmark.Processor;
 
@@ -64,7 +62,7 @@ public Object get(String key) {
                 return null;
             }
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, "-----------------get|" + e);
+            SDKUtil.showLog(TAG, "-----------------get|" + e);
             return null;
         }
     }
@@ -84,7 +82,7 @@ public String getHtmlText(String markdownKey) {
         try {
             return Processor.process(getString(markdownKey), Configuration.builder().forceExtentedProfile().build());
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, "-----------------getHtmlText|" + e);
+            SDKUtil.showLog(TAG, "-----------------getHtmlText|" + e);
             return null;
         }
     }
@@ -111,7 +109,7 @@ public ArrayList getMultipleHtmlText(String markdownKey) {
 
             return multipleHtmlStrings;
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, e.getLocalizedMessage());
             return null;
         }
     }
@@ -320,9 +318,9 @@ public Calendar getDate(String key) {
 
         try {
             String value = getString(key);
-            return ContentstackUtil.parseDate(value, null);
+            return CSUtil.parseDate(value, null);
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, "-----------------getDate|" + e);
+            SDKUtil.showLog(TAG, "-----------------getDate|" + e);
         }
         return null;
     }
@@ -469,7 +467,7 @@ public ArrayList getAllEntries(String refKey, String refContentType) {
                             entryInstance = stackInstance.contentType(refContentType).entry();
                         } catch (Exception e) {
                             entryInstance = new Entry(refContentType);
-                            CSAppUtils.showLog("BuiltObject", e.getLocalizedMessage());
+                            SDKUtil.showLog("BuiltObject", e.getLocalizedMessage());
                         }
                         entryInstance.setUid(model.entryUid);
                         entryInstance.ownerEmailId = model.ownerEmailId;
@@ -489,7 +487,7 @@ public ArrayList getAllEntries(String refKey, String refContentType) {
                 }
             }
         } catch (Exception e) {
-            CSAppUtils.showLog(TAG, e.getLocalizedMessage());
+            SDKUtil.showLog(TAG, e.getLocalizedMessage());
             return null;
         }
 
diff --git a/contentstack/src/main/java/com/contentstack/sdk/IURLRequestHTTP.java b/contentstack/src/main/java/com/contentstack/sdk/IURLRequestHTTP.java
index e0e642db..67b24d3e 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/IURLRequestHTTP.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/IURLRequestHTTP.java
@@ -2,8 +2,6 @@
 
 import android.util.ArrayMap;
 
-import com.contentstack.sdk.utilities.CSAppConstants;
-
 import org.json.JSONObject;
 
 /**
@@ -17,9 +15,9 @@ public interface IURLRequestHTTP {
 
     public ArrayMap getHeaders();
 
-    public void setRequestMethod(CSAppConstants.RequestMethod requestMethod);
+    public void setRequestMethod(SDKConstant.RequestMethod requestMethod);
 
-    public CSAppConstants.RequestMethod getRequestMethod();
+    public SDKConstant.RequestMethod getRequestMethod();
 
     public JSONObject getResponse();
 
diff --git a/contentstack/src/main/java/com/contentstack/sdk/Query.java b/contentstack/src/main/java/com/contentstack/sdk/Query.java
index cf9a8f94..62a76ca5 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/Query.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/Query.java
@@ -4,10 +4,6 @@
 import android.util.ArrayMap;
 import android.util.Log;
 
-import com.contentstack.sdk.utilities.CSAppConstants;
-import com.contentstack.sdk.utilities.CSAppUtils;
-import com.contentstack.sdk.utilities.CSController;
-
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -131,10 +127,10 @@ public Query where(String key, Object value) {
             if (key != null && value != null) {
                 queryValueJSON.put(key, value);
             } else {
-                throwException("where", CSAppConstants.ErrorMessage_QueryFilterException, null);
+                throwException("where", SDKConstant.ErrorMessage_QueryFilterException, null);
             }
         } catch (Exception e) {
-            throwException("where", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("where", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
 
         return this;
@@ -161,10 +157,10 @@ public Query addQuery(String key, String value) {
 
                 urlQueries.put(key, value);
             } else {
-                throwException("and", CSAppConstants.ErrorMessage_QueryFilterException, null);
+                throwException("and", SDKConstant.ErrorMessage_QueryFilterException, null);
             }
         } catch (Exception e) {
-            throwException("and", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("and", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -186,7 +182,7 @@ public Query removeQuery(String key) {
                 urlQueries.remove(key);
             }
         } catch (Exception e) {
-            throwException("and", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("and", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -226,10 +222,10 @@ public Query and(ArrayList queryObjects) {
                 queryValueJSON.put("$and", orValueJson);
 
             } catch (Exception e) {
-                throwException("and", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("and", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("and", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("and", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -271,10 +267,10 @@ public Query or(ArrayList queryObjects) {
                 queryValueJSON.put("$or", orValueJson);
 
             } catch (Exception e) {
-                throwException("or", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("or", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("or", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("or", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -314,10 +310,10 @@ public Query lessThan(String key, Object value) {
 
                 }
             } catch (Exception e) {
-                throwException("lessThan", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("lessThan", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("lessThan", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("lessThan", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -358,10 +354,10 @@ public Query lessThanOrEqualTo(String key, Object value) {
 
                 }
             } catch (Exception e) {
-                throwException("lessThanOrEqualTo", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("lessThanOrEqualTo", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("lessThanOrEqualTo", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("lessThanOrEqualTo", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
         return this;
     }
@@ -400,10 +396,10 @@ public Query greaterThan(String key, Object value) {
 
                 }
             } catch (Exception e) {
-                throwException("greaterThan", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("greaterThan", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("greaterThan", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("greaterThan", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -443,10 +439,10 @@ public Query greaterThanOrEqualTo(String key, Object value) {
 
                 }
             } catch (Exception e) {
-                throwException("greaterThanOrEqualTo", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("greaterThanOrEqualTo", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("greaterThanOrEqualTo", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("greaterThanOrEqualTo", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -492,7 +488,7 @@ public Query notEqualTo(String key, Object value) {
             }
 
         } else {
-            throwException("notEqualTo", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("notEqualTo", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -536,10 +532,10 @@ public Query containedIn(String key, Object[] values) {
 
                 }
             } catch (Exception e) {
-                throwException("containedIn", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("containedIn", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("containedIn", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("containedIn", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -581,10 +577,10 @@ public Query notContainedIn(String key, Object[] values) {
 
                 }
             } catch (Exception e) {
-                throwException("containedIn", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("containedIn", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("containedIn", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("containedIn", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -622,10 +618,10 @@ public Query exists(String key) {
                     queryValueJSON.put(key, queryValue);
                 }
             } catch (Exception e) {
-                throwException("exists", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("exists", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("exists", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("exists", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -661,10 +657,10 @@ public Query notExists(String key) {
                     queryValueJSON.put(key, queryValue);
                 }
             } catch (Exception e) {
-                throwException("notExists", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("notExists", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("notExists", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("notExists", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -718,7 +714,7 @@ public Query includeReference(String[] keys) {
                 objectUidForInclude.put(key);
             }
         } else {
-            throwException("includeReference", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("includeReference", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
         return this;
     }
@@ -747,10 +743,10 @@ public Query tags(String[] tags) {
                 }
                 urlQueries.put("tags", tagsvalue);
             } else {
-                throwException("tags", CSAppConstants.ErrorMessage_QueryFilterException, null);
+                throwException("tags", SDKConstant.ErrorMessage_QueryFilterException, null);
             }
         } catch (Exception e) {
-            throwException("tags", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("tags", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -775,10 +771,10 @@ public Query ascending(String key) {
             try {
                 urlQueries.put("asc", key);
             } catch (Exception e) {
-                throwException("ascending", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("ascending", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("ascending", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("ascending", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
         return this;
     }
@@ -803,10 +799,10 @@ public Query descending(String key) {
             try {
                 urlQueries.put("desc", key);
             } catch (Exception e) {
-                throwException("descending", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("descending", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("descending", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("descending", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
         return this;
     }
@@ -839,10 +835,10 @@ public Query except(ArrayList fieldUid) {
                     objectUidForExcept.put(fieldUid.get(i));
                 }
             } else {
-                throwException("except", CSAppConstants.ErrorMessage_QueryFilterException, null);
+                throwException("except", SDKConstant.ErrorMessage_QueryFilterException, null);
             }
         } catch (Exception e) {
-            throwException("except", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("except", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -872,10 +868,10 @@ public Query except(String[] fieldUids) {
                     objectUidForExcept.put(fieldUids[i]);
                 }
             } else {
-                throwException("except", CSAppConstants.ErrorMessage_QueryFilterException, null);
+                throwException("except", SDKConstant.ErrorMessage_QueryFilterException, null);
             }
         } catch (Exception e) {
-            throwException("except", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("except", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -905,10 +901,10 @@ public Query only(String[] fieldUid) {
                     objectUidForOnly.put(fieldUid[i]);
                 }
             } else {
-                throwException("only", CSAppConstants.ErrorMessage_QueryFilterException, null);
+                throwException("only", SDKConstant.ErrorMessage_QueryFilterException, null);
             }
         } catch (Exception e) {
-            throwException("only", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("only", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -950,10 +946,10 @@ public Query onlyWithReferenceUid(ArrayList fieldUid, String referenceFi
                 objectUidForInclude.put(referenceFieldUid);
 
             } else {
-                throwException("onlyWithReferenceUid", CSAppConstants.ErrorMessage_QueryFilterException, null);
+                throwException("onlyWithReferenceUid", SDKConstant.ErrorMessage_QueryFilterException, null);
             }
         } catch (Exception e) {
-            throwException("onlyWithReferenceUid", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("onlyWithReferenceUid", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -995,10 +991,10 @@ public Query exceptWithReferenceUid(ArrayList fieldUid, String reference
                 objectUidForInclude.put(referenceFieldUid);
 
             } else {
-                throwException("exceptWithReferenceUid", CSAppConstants.ErrorMessage_QueryFilterException, null);
+                throwException("exceptWithReferenceUid", SDKConstant.ErrorMessage_QueryFilterException, null);
             }
         } catch (Exception e) {
-            throwException("exceptWithReferenceUid", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("exceptWithReferenceUid", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -1022,7 +1018,7 @@ public Query count() {
         try {
             urlQueries.put("count", "true");
         } catch (Exception e) {
-            throwException("count", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("count", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -1046,7 +1042,7 @@ public Query includeCount() {
         try {
             urlQueries.put("include_count", "true");
         } catch (Exception e) {
-            throwException("includeCount", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("includeCount", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -1071,7 +1067,7 @@ public Query includeContentType() {
             urlQueries.put("include_content_type", true);
             urlQueries.put("include_global_field_schema", true);
         } catch (Exception e) {
-            throwException("include_content_type", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("include_content_type", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -1095,10 +1091,10 @@ private Query beforeUid(String uid) {
             try {
                 urlQueries.put("before_uid", uid);
             } catch (Exception e) {
-                throwException("beforeUid", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("beforeUid", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("beforeUid", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("beforeUid", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
         return this;
     }
@@ -1121,10 +1117,10 @@ private Query afterUid(String uid) {
             try {
                 urlQueries.put("after_uid", uid);
             } catch (Exception e) {
-                throwException("afterUid", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("afterUid", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("afterUid", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("afterUid", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
         return this;
     }
@@ -1149,7 +1145,7 @@ public Query skip(int number) {
         try {
             urlQueries.put("skip", number);
         } catch (Exception e) {
-            throwException("skip", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("skip", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -1173,7 +1169,7 @@ public Query limit(int number) {
         try {
             urlQueries.put("limit", number);
         } catch (Exception e) {
-            throwException("limit", CSAppConstants.ErrorMessage_QueryFilterException, e);
+            throwException("limit", SDKConstant.ErrorMessage_QueryFilterException, e);
         }
         return this;
     }
@@ -1217,10 +1213,10 @@ public Query regex(String key, String regex) {
                 }
 
             } catch (Exception e) {
-                throwException("matches", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("matches", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("matches", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("matches", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
         return this;
     }
@@ -1274,10 +1270,10 @@ public Query regex(String key, String regex, String modifiers) {
                 }
 
             } catch (Exception e) {
-                throwException("matches", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("matches", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("matches", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("matches", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
         return this;
     }
@@ -1310,10 +1306,10 @@ public Query language(Language language) {
                 }
 
             } catch (Exception e) {
-                throwException("language", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("language", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("language", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("language", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -1340,10 +1336,10 @@ public Query locale(String locale) {
                 }
 
             } catch (Exception e) {
-                throwException("locale", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("locale", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("locale", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("locale", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -1371,10 +1367,10 @@ public Query search(String value) {
                     urlQueries.put("typeahead", value);
                 }
             } catch (Exception e) {
-                throwException("value", CSAppConstants.ErrorMessage_QueryFilterException, e);
+                throwException("value", SDKConstant.ErrorMessage_QueryFilterException, e);
             }
         } else {
-            throwException("value", CSAppConstants.ErrorMessage_QueryFilterException, null);
+            throwException("value", SDKConstant.ErrorMessage_QueryFilterException, null);
         }
 
         return this;
@@ -1426,7 +1422,7 @@ public Query find(QueryResultsCallBack callback) {
 
                     execQuery(null, callback, false);
                 } else {
-                    throwException("find", CSAppConstants.ErrorMessage_FormName, null);
+                    throwException("find", SDKConstant.ErrorMessage_FormName, null);
                     error = new Error();
                     error.setErrorMessage(errorString);
                     error.setErrors(errorHashMap);
@@ -1437,7 +1433,7 @@ public Query find(QueryResultsCallBack callback) {
                 error.setErrors(errorHashMap);
             }
         } catch (Exception e) {
-            throwException("find", CSAppConstants.ErrorMessage_JsonNotProper, null);
+            throwException("find", SDKConstant.ErrorMessage_JsonNotProper, null);
             error = new Error();
             error.setErrorMessage(errorString);
             error.setErrors(errorHashMap);
@@ -1487,7 +1483,7 @@ public Query findOne(SingleQueryResultCallback callBack) {
                     }
 
                 } else {
-                    throwException("find", CSAppConstants.ErrorMessage_FormName, null);
+                    throwException("find", SDKConstant.ErrorMessage_FormName, null);
                     error = new Error();
                     error.setErrorMessage(errorString);
                     error.setErrors(errorHashMap);
@@ -1498,7 +1494,7 @@ public Query findOne(SingleQueryResultCallback callBack) {
                 error.setErrors(errorHashMap);
             }
         } catch (Exception e) {
-            throwException("find", CSAppConstants.ErrorMessage_JsonNotProper, null);
+            throwException("find", SDKConstant.ErrorMessage_JsonNotProper, null);
             error = new Error();
             error.setErrorMessage(errorString);
             error.setErrors(errorHashMap);
@@ -1521,10 +1517,10 @@ public Query findOne(SingleQueryResultCallback callBack) {
      * 
*/ public void cancelRequest() { - CSAppConstants.cancelledCallController.add(CSAppConstants.callController.QUERY.toString()); + SDKConstant.cancelledCallController.add(SDKConstant.callController.QUERY.toString()); if (Contentstack.requestQueue != null) { - Contentstack.requestQueue.cancelAll(CSAppConstants.callController.QUERY.toString()); + Contentstack.requestQueue.cancelAll(SDKConstant.callController.QUERY.toString()); } } @@ -1578,7 +1574,7 @@ protected void setQueryJson(QueryResultsCallBack callback) { } } catch (Exception e) { - throwException("find", CSAppConstants.ErrorMessage_QueryFilterException, e); + throwException("find", SDKConstant.ErrorMessage_QueryFilterException, e); } } @@ -1592,16 +1588,16 @@ protected void execQuery(SingleQueryResultCallback callBack, QueryResultsCallBac ArrayMap headers = getHeader(localHeader); if (headers.size() < 1) { - throwException("find", CSAppConstants.ErrorMessage_CalledDefaultMethod, null); + throwException("find", SDKConstant.ErrorMessage_CalledDefaultMethod, null); } else { if (headers.containsKey("environment")) { urlQueries.put("environment", headers.get("environment")); } mainJSON.put("query", urlQueries); - mainJSON.put("_method", CSAppConstants.RequestMethod.GET.toString()); + mainJSON.put("_method", SDKConstant.RequestMethod.GET.toString()); String mainStringForMD5 = URL + mainJSON.toString() + headers.toString(); - String md5Value = new CSAppUtils().getMD5FromString(mainStringForMD5.trim()); - File cacheFile = new File(CSAppConstants.cacheFolderName + File.separator + md5Value); + String md5Value = new SDKUtil().getMD5FromString(mainStringForMD5.trim()); + File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + md5Value); CachePolicy cachePolicy = CachePolicy.NETWORK_ONLY;//contentTypeInstance.stackInstance.globalCachePolicyForCall; if (cachePolicyForCall != null) { cachePolicy = cachePolicyForCall; @@ -1620,9 +1616,9 @@ protected void execQuery(SingleQueryResultCallback callBack, QueryResultsCallBac if (cacheFile.exists()) { boolean needToSendCall = false; if (maxCacheTimeForCall > 0) { - needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); + needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); } else { - needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) defaultCacheTimeInterval); + needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) defaultCacheTimeInterval); } if (needToSendCall) { fetchFromNetwork(URL, headers, mainJSON, cacheFile.getPath(), callback, callBack); @@ -1634,7 +1630,7 @@ protected void execQuery(SingleQueryResultCallback callBack, QueryResultsCallBac } break; case NETWORK_ELSE_CACHE: - if (CSAppConstants.isNetworkAvailable) { + if (SDKConstant.isNetworkAvailable) { fetchFromNetwork(URL, headers, mainJSON, cacheFile.getPath(), callback, callBack); } else { fetchFromCache(cacheFile, callback, callBack); @@ -1655,7 +1651,7 @@ protected void execQuery(SingleQueryResultCallback callBack, QueryResultsCallBac } catch (Exception e) { - throwException("find", CSAppConstants.ErrorMessage_QueryFilterException, e); + throwException("find", SDKConstant.ErrorMessage_QueryFilterException, e); } } @@ -1665,9 +1661,9 @@ private void fetchFromNetwork(String URL, ArrayMap headers, JSON HashMap urlParams = getUrlParams(jsonMain); if (resultCallback != null) { - new CSBackgroundTask(this, contentTypeInstance.stackInstance, CSController.SINGLEQUERYOBJECT, URL, headers, urlParams, new JSONObject(), cacheFilePath, CSAppConstants.callController.QUERY.toString(), CSAppConstants.RequestMethod.GET, resultCallback); + new CSBackgroundTask(this, contentTypeInstance.stackInstance, SDKController.SINGLE_QUERY_ENTRIES, URL, headers, urlParams, new JSONObject(), cacheFilePath, SDKConstant.callController.QUERY.toString(), SDKConstant.RequestMethod.GET, resultCallback); } else { - new CSBackgroundTask(this, contentTypeInstance.stackInstance, CSController.QUERYOBJECT, URL, headers, urlParams, new JSONObject(), cacheFilePath, CSAppConstants.callController.QUERY.toString(), CSAppConstants.RequestMethod.GET, callback); + new CSBackgroundTask(this, contentTypeInstance.stackInstance, SDKController.GET_QUERY_ENTRIES, URL, headers, urlParams, new JSONObject(), cacheFilePath, SDKConstant.callController.QUERY.toString(), SDKConstant.RequestMethod.GET, callback); } } @@ -1684,7 +1680,7 @@ private HashMap getUrlParams(JSONObject jsonMain) { Object value = queryJSON.opt(key); hashMap.put(key, value); } catch (Exception e) { - CSAppUtils.showLog(TAG, "----------------setQueryJson" + e.toString()); + SDKUtil.showLog(TAG, "----------------setQueryJson" + e.toString()); } } @@ -1702,21 +1698,21 @@ private void fetchFromCache(File cacheFile, QueryResultsCallBack callback, Singl boolean needToSendCall = false; if (maxCacheTimeForCall > 0) { - needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); + needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); } else { - needToSendCall = new CSAppUtils().getResponseTimeFromCacheFile(cacheFile, (int) defaultCacheTimeInterval); + needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) defaultCacheTimeInterval); } if (needToSendCall) { error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); } else { setCacheModel(cacheFile, callback, callBack); } } else { error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); } if (callback != null && error != null) { @@ -1728,7 +1724,7 @@ private void fetchFromCache(File cacheFile, QueryResultsCallBack callback, Singl //ENTRY modeling from cache. private void setCacheModel(File cacheFile, QueryResultsCallBack callback, SingleQueryResultCallback callBack) { - EntriesModel model = new EntriesModel(CSAppUtils.getJsonFromCacheFile(cacheFile), null, true); + EntriesModel model = new EntriesModel(SDKUtil.getJsonFromCacheFile(cacheFile), null, true); List entries = new ArrayList<>(); List objects = model.objectList; int countObject = objects.size(); @@ -1741,7 +1737,7 @@ private void setCacheModel(File cacheFile, QueryResultsCallBack callback, Single } catch (Exception e) { entry = new Entry(formName); entry.setUid(((EntryModel) objects.get(i)).entryUid); - CSAppUtils.showLog(TAG, "----------------getResultObject" + e.toString()); + SDKUtil.showLog(TAG, "----------------getResultObject" + e.toString()); } entry.resultJson = ((EntryModel) objects.get(i)).jsonObject; @@ -1883,10 +1879,10 @@ public Query addParam(String key, String value) { if (key != null && value != null) { urlQueries.put(key, value); } else { - throwException("and", CSAppConstants.ErrorMessage_QueryFilterException, null); + throwException("and", SDKConstant.ErrorMessage_QueryFilterException, null); } } catch (Exception e) { - throwException("and", CSAppConstants.ErrorMessage_QueryFilterException, e); + throwException("and", SDKConstant.ErrorMessage_QueryFilterException, e); } return this; } @@ -1943,10 +1939,10 @@ public Query whereIn(String key, Query queryObject) { inQueryObj.put("$in_query", queryObject.queryValueJSON.toString()); queryValueJSON.put(key, inQueryObj); } catch (Exception e) { - throwException("in_query", CSAppConstants.ErrorMessage_QueryFilterException, e); + throwException("in_query", SDKConstant.ErrorMessage_QueryFilterException, e); } } else { - throwException("in_query", CSAppConstants.ErrorMessage_QueryFilterException, null); + throwException("in_query", SDKConstant.ErrorMessage_QueryFilterException, null); } return this; } @@ -1974,10 +1970,10 @@ public Query whereNotIn(String key, Query queryObject) { inQueryObj.put("$nin_query", queryObject.queryValueJSON.toString()); queryValueJSON.put(key, inQueryObj); } catch (Exception e) { - throwException("nin_query", CSAppConstants.ErrorMessage_QueryFilterException, e); + throwException("nin_query", SDKConstant.ErrorMessage_QueryFilterException, e); } } else { - throwException("nin_query", CSAppConstants.ErrorMessage_QueryFilterException, null); + throwException("nin_query", SDKConstant.ErrorMessage_QueryFilterException, null); } return this; } diff --git a/contentstack/src/main/java/com/contentstack/sdk/QueryResult.java b/contentstack/src/main/java/com/contentstack/sdk/QueryResult.java index 1177ea44..e6dc174b 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/QueryResult.java +++ b/contentstack/src/main/java/com/contentstack/sdk/QueryResult.java @@ -1,7 +1,5 @@ package com.contentstack.sdk; -import com.contentstack.sdk.utilities.CSAppUtils; - import org.json.JSONArray; import org.json.JSONObject; @@ -111,7 +109,7 @@ protected void setJSON(JSONObject jsonobject, List objectList) { } } catch (Exception e) { - CSAppUtils.showLog(TAG, "----------------------QueryResult--setJSON--" + e.toString()); + SDKUtil.showLog(TAG, "----------------------QueryResult--setJSON--" + e.toString()); } } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/utilities/CSAppConstants.java b/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java similarity index 96% rename from contentstack/src/main/java/com/contentstack/sdk/utilities/CSAppConstants.java rename to contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java index 5baaccd2..1c6a9dd4 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/utilities/CSAppConstants.java +++ b/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java @@ -1,11 +1,11 @@ -package com.contentstack.sdk.utilities; +package com.contentstack.sdk; import java.util.ArrayList; /** * @author contentstack.com, Inc */ -public class CSAppConstants { +public class SDKConstant { public static final boolean debug = false; public static boolean isNetworkAvailable = true; @@ -37,8 +37,8 @@ public static enum callController { STACK, ASSET, SYNC, - CONTENTTYPES, - ASSETLIBRARY; + CONTENT_TYPES, + ASSET_LIBRARY; } diff --git a/contentstack/src/main/java/com/contentstack/sdk/SDKController.java b/contentstack/src/main/java/com/contentstack/sdk/SDKController.java new file mode 100755 index 00000000..c695e83e --- /dev/null +++ b/contentstack/src/main/java/com/contentstack/sdk/SDKController.java @@ -0,0 +1,44 @@ +package com.contentstack.sdk; + +/** + * The type Sdk controller. + * + * @author contentstack.com, Inc + */ +public class SDKController { + + /** + * The constant GET_QUERY_ENTRIES. + */ + public static final String GET_QUERY_ENTRIES = "getQueryEntries"; + + /** + * The constant SINGLE_QUERY_ENTRIES. + */ + public static final String SINGLE_QUERY_ENTRIES = "getSingleQueryEntries"; + + /** + * The constant GET_ENTRY. + */ + public static final String GET_ENTRY = "getEntry"; + + /** + * The constant GET_ALL_ASSETS. + */ + public static final String GET_ALL_ASSETS = "getAllAssets"; + + /** + * The constant GET_ASSETS. + */ + public static final String GET_ASSETS = "getAssets"; + + /** + * The constant GET_SYNC. + */ + public static final String GET_SYNC = "getSync"; + + /** + * The constant GET_CONTENT_TYPES. + */ + public static final String GET_CONTENT_TYPES = "getContentTypes"; +} diff --git a/contentstack/src/main/java/com/contentstack/sdk/utilities/CSAppUtils.java b/contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java similarity index 98% rename from contentstack/src/main/java/com/contentstack/sdk/utilities/CSAppUtils.java rename to contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java index b8e1ed09..01bc3fe7 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/utilities/CSAppUtils.java +++ b/contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java @@ -1,4 +1,4 @@ -package com.contentstack.sdk.utilities; +package com.contentstack.sdk; import android.annotation.SuppressLint; import android.util.Log; @@ -21,13 +21,13 @@ /** * @author contentstack.com */ -public class CSAppUtils { +public class SDKUtil { - public CSAppUtils() { + public SDKUtil() { } public static void showLog(String tag, String message) { - if (CSAppConstants.debug) { + if (SDKConstant.debug) { Log.i(tag, message); } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index 0293bc5d..d93d6bb4 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -4,10 +4,6 @@ import android.util.ArrayMap; import android.util.Log; -import com.contentstack.sdk.utilities.CSAppConstants; -import com.contentstack.sdk.utilities.CSAppUtils; -import com.contentstack.sdk.utilities.CSController; - import org.jetbrains.annotations.NotNull; import org.json.JSONException; import org.json.JSONObject; @@ -58,8 +54,7 @@ private Stack() throws IllegalAccessException { protected Stack(String stackApiKey) { this.stackApiKey = stackApiKey; - this.localHeader = new ArrayMap(); - + this.localHeader = new ArrayMap<>(); } protected void setConfig(Config config) { @@ -71,7 +66,6 @@ protected void setConfig(Config config) { if (!TextUtils.isEmpty(config.environment)) { setHeader("environment", config.environment); } - if (!config.region.name().isEmpty()) { String region = config.region.name().toLowerCase(); if (!region.equalsIgnoreCase("us")) { @@ -129,7 +123,6 @@ public void sync(SyncResultCallBack syncCallBack) { public ContentType contentType(String contentTypeName) { ContentType contentType = new ContentType(contentTypeName); contentType.setStackInstance(this); - return contentType; } @@ -148,7 +141,6 @@ public ContentType contentType(String contentTypeName) { public Asset asset(String uid) { Asset asset = new Asset(uid); asset.setStackInstance(this); - return asset; } @@ -166,7 +158,6 @@ public Asset asset(String uid) { protected Asset asset() { Asset asset = new Asset(); asset.setStackInstance(this); - return asset; } @@ -244,7 +235,7 @@ public void removeHeader(String key) { *

Example :
*
-     *              stack.setHeader("custom_key", "custom_value");
+     *              stack.setHeader("key", "value");
      *              
*/ public void setHeader(String key, String value) { @@ -271,9 +262,6 @@ public void setHeader(String key, String value) { * imageParams.put("height",100); * imageUrl = Stack.ImageTransform(image_url, parameters); * stack.ImageTransform(image_url, parameters); - * - * - * * */ public String ImageTransform(String image_url, LinkedHashMap parameters) { @@ -284,17 +272,13 @@ public String ImageTransform(String image_url, LinkedHashMap par private String getImageUrl() { - if (imageParams == null || imageParams.size() == 0) { return imageTransformationUrl; } - for (Map.Entry param : imageParams.entrySet()) { try { - String paramKey = param.getKey(); String paramValue = param.getValue().toString(); - final String encodedKey = URLEncoder.encode(paramKey, "UTF-8"); final String encodedValue = URLEncoder.encode(paramValue, "UTF-8"); if (!imageTransformationUrl.contains("?")) { @@ -302,12 +286,10 @@ private String getImageUrl() { } else { imageTransformationUrl += "&" + encodedKey + "=" + encodedValue; } - } catch (UnsupportedEncodingException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } } - return imageTransformationUrl; } @@ -332,7 +314,6 @@ private String getImageUrl() { * */ public void getContentTypes(JSONObject params, final ContentTypesCallback callback) { - try { String URL = "/" + this.VERSION + "/content_types"; ArrayMap headers = getHeader(localHeader); @@ -341,11 +322,8 @@ public void getContentTypes(JSONObject params, final ContentTypesCallback callba } Iterator keys = params.keys(); while (keys.hasNext()) { - // loop to get the dynamic key String key = (String) keys.next(); - // get the value of the dynamic key Object value = params.opt(key); - // do something here with the value... params.put(key, value); } @@ -353,13 +331,12 @@ public void getContentTypes(JSONObject params, final ContentTypesCallback callba params.put("environment", headers.get("environment")); params.put("include_count", true); } - fetchContentTypes(URL, params, headers, null, callback); } catch (Exception e) { Error error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_JsonNotProper); + error.setErrorMessage(SDKConstant.ErrorMessage_JsonNotProper); callback.onRequestFail(ResponseType.UNKNOWN, error); } } @@ -368,7 +345,7 @@ public void getContentTypes(JSONObject params, final ContentTypesCallback callba private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap headers, String cacheFilePath, ContentTypesCallback callback) { if (callback != null) { HashMap urlParams = getUrlParams(urlQueries); - new CSBackgroundTask(this, this, CSController.FETCHCONTENTTYPES, urlString, headers, urlParams, new JSONObject(), cacheFilePath, CSAppConstants.callController.CONTENTTYPES.toString(), false, CSAppConstants.RequestMethod.GET, callback); + new CSBackgroundTask(this, this, SDKController.GET_CONTENT_TYPES, urlString, headers, urlParams, new JSONObject(), cacheFilePath, SDKConstant.callController.CONTENT_TYPES.toString(), false, SDKConstant.RequestMethod.GET, callback); } } @@ -409,9 +386,7 @@ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncC * and the details of the content that was deleted or updated. *

Example :
*
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  stack.syncToken(sync_token, new SyncResultCallBack() ){ }
-     *
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
+ * */ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { try { @@ -432,8 +407,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); @@ -637,7 +612,7 @@ public void onCompletion(SyncStack syncStack, Error error) { }); } catch (Exception e) { Error error = new Error(); - error.setErrorMessage(CSAppConstants.ErrorMessage_JsonNotProper); + error.setErrorMessage(SDKConstant.ErrorMessage_JsonNotProper); callback.onRequestFail(ResponseType.UNKNOWN, error); } } @@ -646,7 +621,7 @@ public void onCompletion(SyncStack syncStack, Error error) { private void fetchFromNetwork(String urlString, JSONObject urlQueries, ArrayMap headers, String cacheFilePath, SyncResultCallBack callback) { if (callback != null) { HashMap urlParams = getUrlParams(urlQueries); - new CSBackgroundTask(this, this, CSController.FETCHSYNC, urlString, headers, urlParams, new JSONObject(), cacheFilePath, CSAppConstants.callController.SYNC.toString(), false, CSAppConstants.RequestMethod.GET, callback); + new CSBackgroundTask(this, this, SDKController.GET_SYNC, urlString, headers, urlParams, new JSONObject(), cacheFilePath, SDKConstant.callController.SYNC.toString(), false, SDKConstant.RequestMethod.GET, callback); } } @@ -661,7 +636,7 @@ private HashMap getUrlParams(JSONObject urlQueriesJSON) { Object value = urlQueriesJSON.opt(key); hashMap.put(key, value); } catch (Exception e) { - CSAppUtils.showLog(TAG, e.getLocalizedMessage()); + SDKUtil.showLog(TAG, e.getLocalizedMessage()); } } return hashMap; diff --git a/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java b/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java index b115f900..9c867fc2 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java @@ -1,7 +1,5 @@ package com.contentstack.sdk; -import com.contentstack.sdk.utilities.CSAppUtils; - import org.json.JSONArray; import org.json.JSONObject; @@ -93,7 +91,7 @@ protected void setJSON(JSONObject jsonobject) { } } } catch (Exception e) { - CSAppUtils.showLog(TAG, e.getLocalizedMessage()); + SDKUtil.showLog(TAG, e.getLocalizedMessage()); } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/utilities/CSController.java b/contentstack/src/main/java/com/contentstack/sdk/utilities/CSController.java deleted file mode 100755 index e0250ba6..00000000 --- a/contentstack/src/main/java/com/contentstack/sdk/utilities/CSController.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.contentstack.sdk.utilities; - -/** - * @author contentstack.com, Inc - */ -public class CSController { - - public static final String QUERYOBJECT = "getQueryEntries"; - - public static final String SINGLEQUERYOBJECT = "getSingleQueryEntries"; - - public static final String FETCHENTRY = "getEntry"; - - public static final String FETCHALLASSETS = "getAllAssets"; - - public static final String FETCHASSETS = "getAssets"; - - public static final String FETCHSYNC = "getSync"; - - public static final String FETCHCONTENTTYPES = "getContentTypes"; -} diff --git a/contentstack/src/test/java/com/contentstack/sdk/AssetTest.java b/contentstack/src/test/java/com/contentstack/sdk/AssetTest.java new file mode 100644 index 00000000..9c679d1f --- /dev/null +++ b/contentstack/src/test/java/com/contentstack/sdk/AssetTest.java @@ -0,0 +1,24 @@ +package com.contentstack.sdk; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class AssetTest { + + @Test + void setTags() { + } + + @Test + void addParam() { + } + + @Test + void includeDimension() { + } + + @Test + void includeFallback() { + } +} \ No newline at end of file From cc457ed5a641949aa247a94aaba4ce858434db94 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Thu, 27 Apr 2023 17:33:26 +0530 Subject: [PATCH 04/17] feat:[CS-37836]/region-azure-eu-include-metadata - Added support for include metadata in asset, entry and query class - Added support of Region for Azure-EU - General code and API document improvements - Breaking changes : PublishType Enums are updated to all CAPS - Kotlin support removed due to build issue --- .../main/java/com/contentstack/sdk/Asset.java | 8 +- .../com/contentstack/sdk/AssetLibrary.java | 12 +- .../contentstack/sdk/CSBackgroundTask.java | 18 +- .../contentstack/sdk/CSConnectionRequest.java | 4 +- .../contentstack/sdk/CSHttpConnection.java | 16 +- .../contentstack/sdk/ConnectionStatus.java | 6 +- .../com/contentstack/sdk/ContentType.java | 62 +++---- .../com/contentstack/sdk/Contentstack.java | 22 +-- .../main/java/com/contentstack/sdk/Entry.java | 8 +- .../main/java/com/contentstack/sdk/Query.java | 156 ++++++++-------- .../com/contentstack/sdk/SDKConstant.java | 171 +++++++++++++++--- .../main/java/com/contentstack/sdk/Stack.java | 4 +- 12 files changed, 297 insertions(+), 190 deletions(-) diff --git a/contentstack/src/main/java/com/contentstack/sdk/Asset.java b/contentstack/src/main/java/com/contentstack/sdk/Asset.java index 2e273363..6e96bec4 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Asset.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Asset.java @@ -419,7 +419,7 @@ public void fetch(FetchResultCallback callback) { break; case NETWORK_ELSE_CACHE: - if (SDKConstant.isNetworkAvailable) { + if (SDKConstant.IS_NETWORK_AVAILABLE) { fetchFromNetwork(urlEndpoint, urlQueries, headers, cacheFile.getPath(), callback); } else { fetchFromCache(cacheFile, callback); @@ -429,7 +429,7 @@ public void fetch(FetchResultCallback callback) { } catch (Exception e) { Error error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_JsonNotProper); + error.setErrorMessage(SDKConstant.PLEASE_PROVIDE_VALID_JSON); callback.onRequestFail(ResponseType.UNKNOWN, error); } } @@ -449,13 +449,13 @@ private void fetchFromCache(File cacheFile, FetchResultCallback callback) { needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) MAX_CACHE_TIME_FOR_CALL); if (needToSendCall) { error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ENTRY_IS_NOT_PRESENT_IN_CACHE); } else { setCacheModel(cacheFile, callback); } } else { error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ENTRY_IS_NOT_PRESENT_IN_CACHE); } if (callback != null && error != null) { diff --git a/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java b/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java index 042a6d44..e47cf2b0 100644 --- a/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java +++ b/contentstack/src/main/java/com/contentstack/sdk/AssetLibrary.java @@ -116,7 +116,7 @@ public AssetLibrary sort(String key, ORDERBY orderby) { break; } } catch (Exception e) { - throwException("sort", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("sort", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; @@ -137,7 +137,7 @@ public AssetLibrary includeCount() { try { urlQueries.put("include_count", "true"); } catch (Exception e) { - throwException("includeCount", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("includeCount", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -157,7 +157,7 @@ public AssetLibrary includeRelativeUrl() { try { urlQueries.put("relative_urls", "true"); } catch (Exception e) { - throwException("relative_urls", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("relative_urls", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -247,7 +247,7 @@ public void fetchAll(FetchAssetsCallback assetsCallback) { fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), assetsCallback); break; case NETWORK_ELSE_CACHE: - if (SDKConstant.isNetworkAvailable) { + if (SDKConstant.IS_NETWORK_AVAILABLE) { fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), assetsCallback); } else { fetchFromCache(cacheFile, assetsCallback); @@ -274,13 +274,13 @@ private void fetchFromCache(File cacheFile, FetchAssetsCallback callback) { needToSendCall = new SDKUtil().getResponseTimeFromCacheFile(cacheFile, (int) maxCacheTimeForCall); if (needToSendCall) { error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ENTRY_IS_NOT_PRESENT_IN_CACHE); } else { setCacheModel(cacheFile, callback); } } else { error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ENTRY_IS_NOT_PRESENT_IN_CACHE); } if (callback != null && error != null) { diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java b/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java index ca5fa04c..ac0b1461 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSBackgroundTask.java @@ -13,7 +13,7 @@ class CSBackgroundTask { public CSBackgroundTask(Query queryInstance, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, SDKConstant.RequestMethod method, ResultCallBack callback) { - if (SDKConstant.isNetworkAvailable) { + if (SDKConstant.IS_NETWORK_AVAILABLE) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -32,7 +32,7 @@ public CSBackgroundTask(Query queryInstance, Stack stackInstance, String control } public CSBackgroundTask(Entry entryInstance, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean isOffline, SDKConstant.RequestMethod method, ResultCallBack callBack) { - if (SDKConstant.isNetworkAvailable) { + if (SDKConstant.IS_NETWORK_AVAILABLE) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -50,7 +50,7 @@ public CSBackgroundTask(Entry entryInstance, Stack stackInstance, String control } public CSBackgroundTask(AssetLibrary assetLibrary, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean isOffline, SDKConstant.RequestMethod method, ResultCallBack callback) { - if (SDKConstant.isNetworkAvailable) { + if (SDKConstant.IS_NETWORK_AVAILABLE) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -68,7 +68,7 @@ public CSBackgroundTask(AssetLibrary assetLibrary, Stack stackInstance, String c } public CSBackgroundTask(Asset asset, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlQueries, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean isOffline, SDKConstant.RequestMethod method, ResultCallBack callback) { - if (SDKConstant.isNetworkAvailable) { + if (SDKConstant.IS_NETWORK_AVAILABLE) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -88,7 +88,7 @@ public CSBackgroundTask(Asset asset, Stack stackInstance, String controller, Str public CSBackgroundTask(Stack stack, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlParams, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean b, SDKConstant.RequestMethod method, ResultCallBack callback) { - if (SDKConstant.isNetworkAvailable) { + if (SDKConstant.IS_NETWORK_AVAILABLE) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -109,7 +109,7 @@ public CSBackgroundTask(Stack stack, Stack stackInstance, String controller, Str public CSBackgroundTask(ContentType contentType, Stack stackInstance, String controller, String url, ArrayMap headers, HashMap urlParams, JSONObject jsonMain, String cacheFilePath, String requestInfo, boolean b, SDKConstant.RequestMethod method, ResultCallBack callback) { - if (SDKConstant.isNetworkAvailable) { + if (SDKConstant.IS_NETWORK_AVAILABLE) { if (headers != null && headers.size() > 0) { String URL = stackInstance.PROTOCOL + stackInstance.URL + url; @@ -130,8 +130,8 @@ public CSBackgroundTask(ContentType contentType, Stack stackInstance, String con private void sendErrorToUser(ResultCallBack callbackObject) { Error error = new Error(); - error.setErrorCode(SDKConstant.NONETWORKCONNECTION); - error.setErrorMessage(SDKConstant.ErrorMessage_NoNetwork); + error.setErrorCode(SDKConstant.NO_NETWORK_CONNECTION); + error.setErrorMessage(SDKConstant.NOT_AVAILABLE); if (callbackObject != null) { callbackObject.onRequestFail(ResponseType.UNKNOWN, error); } @@ -139,7 +139,7 @@ private void sendErrorToUser(ResultCallBack callbackObject) { private void sendErrorForHeader(ResultCallBack callbackObject) { Error error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_CalledDefaultMethod); + error.setErrorMessage(SDKConstant.STACK_FIRST); if (callbackObject != null) { callbackObject.onRequestFail(ResponseType.UNKNOWN, error); } diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java b/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java index b11b5a3b..8eafd183 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java @@ -164,7 +164,7 @@ public void onRequestFailed(JSONObject error, int statusCode, ResultCallBack cal errorMessage = e.getLocalizedMessage(); } if (errorMessage == null || (!(errorMessage.length() > 0))) { - errorMessage = SDKConstant.ErrorMessage_Default; + errorMessage = SDKConstant.ERROR_MESSAGE_DEFAULT; } errorObject.setErrorCode(errorCode); errorObject.setErrorMessage(errorMessage); @@ -305,7 +305,7 @@ protected void createFileIntoCacheDir(Object jsonObject) { file.close(); } catch (Exception e) { Error error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_SavingNetworkCallResponseForCache); + error.setErrorMessage(SDKConstant.NETWORK_CALL_RESPONSE); HashMap hashMap = new HashMap(); hashMap.put("error", e.getLocalizedMessage()); error.setErrors(hashMap); diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java index 08dc6f70..77e8786f 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java @@ -222,7 +222,7 @@ private String getParams(HashMap params) { @Override public void send() { String url = null; - String protocol = SDKConstant.URLSCHEMA_HTTPS; + String protocol = SDKConstant.PROTOCOL; int requestId = getRequestId(requestMethod); final HashMap headers = new HashMap<>(); int count = this.headers.size(); @@ -303,7 +303,7 @@ private void generateBuiltError(VolleyError error) { try { int statusCode = 0; responseJSON = new JSONObject(); - responseJSON.put("error_message", SDKConstant.ErrorMessage_Default); + responseJSON.put("error_message", SDKConstant.ERROR_MESSAGE_DEFAULT); if (error != null) { @@ -316,27 +316,27 @@ private void generateBuiltError(VolleyError error) { } else { if (error.toString().equalsIgnoreCase("NoConnectionError")) { - responseJSON.put("error_message", SDKConstant.ErrorMessage_VolleyNoConnectionError); + responseJSON.put("error_message", SDKConstant.CONNECTION_ERROR); } else if (error.toString().equalsIgnoreCase("AuthFailureError")) { - responseJSON.put("error_message", SDKConstant.ErrorMessage_VolleyAuthFailureError); + responseJSON.put("error_message", SDKConstant.AUTHENTICATION_NOT_PRESENT); } else if (error.toString().equalsIgnoreCase("NetworkError")) { - responseJSON.put("error_message", SDKConstant.ErrorMessage_NoNetwork); + responseJSON.put("error_message", SDKConstant.NOT_AVAILABLE); } else if (error.toString().equalsIgnoreCase("ParseError")) { - responseJSON.put("error_message", SDKConstant.ErrorMessage_VolleyParseError); + responseJSON.put("error_message", SDKConstant.PARSING_ERROR); } else if (error.toString().equalsIgnoreCase("ServerError")) { - responseJSON.put("error_message", SDKConstant.ErrorMessage_VolleyServerError); + responseJSON.put("error_message", SDKConstant.TRY_AGAIN); } else if (error.toString().equalsIgnoreCase("TimeoutError")) { - responseJSON.put("error_message", SDKConstant.ErrorMessage_VolleyServerError); + responseJSON.put("error_message", SDKConstant.TRY_AGAIN); } else { if (error.getMessage() != null) { diff --git a/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java b/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java index 18a844f9..90e42531 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java +++ b/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java @@ -32,15 +32,15 @@ public void onReceive(Context context, Intent intent) { Contentstack.isNetworkAvailable(context); - if (!isNetworkAvailable) { + if (!IS_NETWORK_AVAILABLE) { //no net connection - isNetworkAvailable = false; + IS_NETWORK_AVAILABLE = false; } else { try { JSONObject jsonObj = null; JSONObject headerObject = null; HashMap headerGroup = new HashMap<>(); - isNetworkAvailable = true; + IS_NETWORK_AVAILABLE = true; File offlineCallsFolder = new File(context.getDir("OfflineCalls", 0).getPath()); if (offlineCallsFolder.isDirectory()) { diff --git a/contentstack/src/main/java/com/contentstack/sdk/ContentType.java b/contentstack/src/main/java/com/contentstack/sdk/ContentType.java index 5dfe8598..f6e2dca6 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/ContentType.java +++ b/contentstack/src/main/java/com/contentstack/sdk/ContentType.java @@ -27,7 +27,7 @@ private ContentType() { protected ContentType(String contentTypeName) { this.contentTypeName = contentTypeName; - this.localHeader = new ArrayMap(); + this.localHeader = new ArrayMap<>(); } protected void setStackInstance(Stack stack) { @@ -35,7 +35,6 @@ protected void setStackInstance(Stack stack) { this.stackHeader = stack.localHeader; } - /** * To set headers for Contentstack rest calls. *
@@ -46,10 +45,10 @@ protected void setStackInstance(Stack stack) { * *

Example :
*
-     *                            Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment");
-     *                            ContentType contentType = stack.contentType("form_name");
- * contentType.setHeader("custom_key", "custom_value"); - *
+ * Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment"); + * ContentType contentType = stack.contentType("form_name");
+ * contentType.setHeader("custom_key", "custom_value"); + * */ public void setHeader(String key, String value) { if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) { @@ -64,10 +63,10 @@ public void setHeader(String key, String value) { * *

Example :
*
-     *                        Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment");
-     *                        ContentType contentType = stack.contentType("form_name");
- * contentType.removeHeader("custom_header_key"); - *
+ * Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment"); + * ContentType contentType = stack.contentType("form_name");
+ * contentType.removeHeader("custom_header_key"); + * */ public void removeHeader(String key) { if (!TextUtils.isEmpty(key)) { @@ -135,61 +134,48 @@ public Query query() { * *

Example :
*
-     *                                 ContentType  contentType = stack.contentType("content_type_uid");
-     *                                 JSONObject params = new JSONObject();
-     *                                 params.put("include_snippet_schema", true);
-     *                                 params.put("limit", 3);
-     *                                 contentType.fetch(new ContentTypesCallback() {
-     *                                 @Override
-     *                                 public void onCompletion(ContentTypesModel contentTypesModel, Error error) {
-     *                                 if (error==null){
-     *
-     *                                 }else {
-     *
-     *                                 }
-     *                                 }
-     *                                 });
-     *                                 
+ * ContentType contentType = stack.contentType("content_type_uid"); + * JSONObject params = new JSONObject(); + * params.put("include_snippet_schema", true); + * params.put("limit", 3); + * contentType.fetch(new ContentTypesCallback() { + * @Override + * public void onCompletion(ContentTypesModel contentTypesModel, Error error) { + * if (error==null){ + * }else { + * } + * } + * }); + * */ public void fetch(JSONObject params, final ContentTypesCallback callback) { - try { - String URL = "/" + stackInstance.VERSION + "/content_types/" + contentTypeName; ArrayMap headers = getHeader(localHeader); if (params == null) { params = new JSONObject(); } - Iterator keys = params.keys(); while (keys.hasNext()) { - // loop to get the dynamic key String key = (String) keys.next(); - // get the value of the dynamic key Object value = params.opt(key); - // do something here with the value... params.put(key, value); } - if (headers.containsKey("environment")) { params.put("environment", headers.get("environment")); } - if (contentTypeName != null && !contentTypeName.isEmpty()) { fetchContentTypes(URL, params, headers, null, callback); } else { Error error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_JsonNotProper); + error.setErrorMessage(SDKConstant.PLEASE_PROVIDE_VALID_JSON); callback.onRequestFail(ResponseType.UNKNOWN, error); } - - } catch (Exception e) { - Error error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_JsonNotProper); + error.setErrorMessage(SDKConstant.PLEASE_PROVIDE_VALID_JSON); callback.onRequestFail(ResponseType.UNKNOWN, error); } diff --git a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java index bbaa1595..51bdc69c 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java @@ -22,7 +22,7 @@ */ public class Contentstack { - private static final String TAG = "Contentstack"; + private static final String TAG = Contentstack.class.getSimpleName(); protected static RequestQueue requestQueue; private static Contentstack instance; protected static Context context = null; @@ -61,16 +61,16 @@ public static Stack stack(Context context, String apiKey, String deliveryToken, config.setEnvironment(environment); return initializeStack(context, apiKey, deliveryToken, config); } else { - throw new Exception(SDKConstant.ErrorMessage_Stack_Environment_IsNull); + throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_ENVIRONMENT_IS_NULL); } } else { - throw new Exception(SDKConstant.ErrorMessage_Stack_AccessToken_IsNull); + throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_ACCESS_TOKEN_IS_NULL); } } else { - throw new Exception(SDKConstant.ErrorMessage_StackApiKeyIsNull); + throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_API_KEY_IS_NULL); } } else { - throw new Exception(SDKConstant.ErrorMessage_StackContextIsNull); + throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_CONTEXT_IS_NULL); } } @@ -106,16 +106,16 @@ public static Stack stack(Context context, String apiKey, String deliveryToken, } return initializeStack(context, apiKey, deliveryToken, config); } else { - throw new Exception(SDKConstant.ErrorMessage_Stack_Environment_IsNull); + throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_ENVIRONMENT_IS_NULL); } } else { - throw new Exception(SDKConstant.ErrorMessage_Stack_AccessToken_IsNull); + throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_ACCESS_TOKEN_IS_NULL); } } else { - throw new Exception(SDKConstant.ErrorMessage_StackApiKeyIsNull); + throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_API_KEY_IS_NULL); } } else { - throw new Exception(SDKConstant.ErrorMessage_StackContextIsNull); + throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_CONTEXT_IS_NULL); } } @@ -198,8 +198,8 @@ private static void clearCache(Context context) { protected static void isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager.getNetworkInfo(0) != null || connectivityManager.getNetworkInfo(1).getState() != null) { - SDKConstant.isNetworkAvailable = connectivityManager.getActiveNetworkInfo() != null; + SDKConstant.IS_NETWORK_AVAILABLE = connectivityManager.getActiveNetworkInfo() != null; } else - SDKConstant.isNetworkAvailable = connectivityManager.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED || connectivityManager.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED; + SDKConstant.IS_NETWORK_AVAILABLE = connectivityManager.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED || connectivityManager.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED; } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/Entry.java b/contentstack/src/main/java/com/contentstack/sdk/Entry.java index aae22364..2e83e300 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Entry.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Entry.java @@ -1131,7 +1131,7 @@ public void fetch(EntryResultCallBack callBack) { case NETWORK_ELSE_CACHE: - if (SDKConstant.isNetworkAvailable) { + if (SDKConstant.IS_NETWORK_AVAILABLE) { fetchFromNetwork(URL, urlQueries, cacheFile.getPath(), callBack); } else { fetchFromCache(cacheFile, callBack); @@ -1142,7 +1142,7 @@ public void fetch(EntryResultCallBack callBack) { } } else { - throwException(SDKConstant.ErrorMessage_EntryUID, null, callBack); + throwException(SDKConstant.PLEASE_SET_ENTRY_UID, null, callBack); } } catch (Exception e) { throwException(null, e, callBack); @@ -1183,14 +1183,14 @@ private void fetchFromCache(File cacheFile, EntryResultCallBack callback) { if (needToSendCall) { error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ENTRY_IS_NOT_PRESENT_IN_CACHE); } else { setCacheModel(cacheFile, callback); } } else { error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ENTRY_IS_NOT_PRESENT_IN_CACHE); } if (callback != null && error != null) { diff --git a/contentstack/src/main/java/com/contentstack/sdk/Query.java b/contentstack/src/main/java/com/contentstack/sdk/Query.java index 62a76ca5..08d87f7d 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Query.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Query.java @@ -127,10 +127,10 @@ public Query where(String key, Object value) { if (key != null && value != null) { queryValueJSON.put(key, value); } else { - throwException("where", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("where", SDKConstant.PROVIDE_VALID_PARAMS, null); } } catch (Exception e) { - throwException("where", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("where", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; @@ -157,10 +157,10 @@ public Query addQuery(String key, String value) { urlQueries.put(key, value); } else { - throwException("and", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("and", SDKConstant.PROVIDE_VALID_PARAMS, null); } } catch (Exception e) { - throwException("and", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("and", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -182,7 +182,7 @@ public Query removeQuery(String key) { urlQueries.remove(key); } } catch (Exception e) { - throwException("and", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("and", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -222,10 +222,10 @@ public Query and(ArrayList queryObjects) { queryValueJSON.put("$and", orValueJson); } catch (Exception e) { - throwException("and", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("and", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("and", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("and", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -267,10 +267,10 @@ public Query or(ArrayList queryObjects) { queryValueJSON.put("$or", orValueJson); } catch (Exception e) { - throwException("or", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("or", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("or", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("or", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -310,10 +310,10 @@ public Query lessThan(String key, Object value) { } } catch (Exception e) { - throwException("lessThan", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("lessThan", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("lessThan", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("lessThan", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -354,10 +354,10 @@ public Query lessThanOrEqualTo(String key, Object value) { } } catch (Exception e) { - throwException("lessThanOrEqualTo", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("lessThanOrEqualTo", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("lessThanOrEqualTo", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("lessThanOrEqualTo", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; } @@ -396,10 +396,10 @@ public Query greaterThan(String key, Object value) { } } catch (Exception e) { - throwException("greaterThan", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("greaterThan", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("greaterThan", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("greaterThan", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -439,10 +439,10 @@ public Query greaterThanOrEqualTo(String key, Object value) { } } catch (Exception e) { - throwException("greaterThanOrEqualTo", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("greaterThanOrEqualTo", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("greaterThanOrEqualTo", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("greaterThanOrEqualTo", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -488,7 +488,7 @@ public Query notEqualTo(String key, Object value) { } } else { - throwException("notEqualTo", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("notEqualTo", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -532,10 +532,10 @@ public Query containedIn(String key, Object[] values) { } } catch (Exception e) { - throwException("containedIn", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("containedIn", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("containedIn", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("containedIn", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -577,10 +577,10 @@ public Query notContainedIn(String key, Object[] values) { } } catch (Exception e) { - throwException("containedIn", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("containedIn", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("containedIn", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("containedIn", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -618,10 +618,10 @@ public Query exists(String key) { queryValueJSON.put(key, queryValue); } } catch (Exception e) { - throwException("exists", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("exists", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("exists", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("exists", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -657,10 +657,10 @@ public Query notExists(String key) { queryValueJSON.put(key, queryValue); } } catch (Exception e) { - throwException("notExists", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("notExists", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("notExists", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("notExists", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -714,7 +714,7 @@ public Query includeReference(String[] keys) { objectUidForInclude.put(key); } } else { - throwException("includeReference", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("includeReference", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; } @@ -743,10 +743,10 @@ public Query tags(String[] tags) { } urlQueries.put("tags", tagsvalue); } else { - throwException("tags", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("tags", SDKConstant.PROVIDE_VALID_PARAMS, null); } } catch (Exception e) { - throwException("tags", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("tags", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -771,10 +771,10 @@ public Query ascending(String key) { try { urlQueries.put("asc", key); } catch (Exception e) { - throwException("ascending", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("ascending", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("ascending", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("ascending", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; } @@ -799,10 +799,10 @@ public Query descending(String key) { try { urlQueries.put("desc", key); } catch (Exception e) { - throwException("descending", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("descending", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("descending", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("descending", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; } @@ -835,10 +835,10 @@ public Query except(ArrayList fieldUid) { objectUidForExcept.put(fieldUid.get(i)); } } else { - throwException("except", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("except", SDKConstant.PROVIDE_VALID_PARAMS, null); } } catch (Exception e) { - throwException("except", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("except", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -868,10 +868,10 @@ public Query except(String[] fieldUids) { objectUidForExcept.put(fieldUids[i]); } } else { - throwException("except", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("except", SDKConstant.PROVIDE_VALID_PARAMS, null); } } catch (Exception e) { - throwException("except", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("except", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -901,10 +901,10 @@ public Query only(String[] fieldUid) { objectUidForOnly.put(fieldUid[i]); } } else { - throwException("only", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("only", SDKConstant.PROVIDE_VALID_PARAMS, null); } } catch (Exception e) { - throwException("only", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("only", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -946,10 +946,10 @@ public Query onlyWithReferenceUid(ArrayList fieldUid, String referenceFi objectUidForInclude.put(referenceFieldUid); } else { - throwException("onlyWithReferenceUid", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("onlyWithReferenceUid", SDKConstant.PROVIDE_VALID_PARAMS, null); } } catch (Exception e) { - throwException("onlyWithReferenceUid", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("onlyWithReferenceUid", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -991,10 +991,10 @@ public Query exceptWithReferenceUid(ArrayList fieldUid, String reference objectUidForInclude.put(referenceFieldUid); } else { - throwException("exceptWithReferenceUid", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("exceptWithReferenceUid", SDKConstant.PROVIDE_VALID_PARAMS, null); } } catch (Exception e) { - throwException("exceptWithReferenceUid", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("exceptWithReferenceUid", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -1018,7 +1018,7 @@ public Query count() { try { urlQueries.put("count", "true"); } catch (Exception e) { - throwException("count", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("count", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -1042,7 +1042,7 @@ public Query includeCount() { try { urlQueries.put("include_count", "true"); } catch (Exception e) { - throwException("includeCount", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("includeCount", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -1067,7 +1067,7 @@ public Query includeContentType() { urlQueries.put("include_content_type", true); urlQueries.put("include_global_field_schema", true); } catch (Exception e) { - throwException("include_content_type", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("include_content_type", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -1091,10 +1091,10 @@ private Query beforeUid(String uid) { try { urlQueries.put("before_uid", uid); } catch (Exception e) { - throwException("beforeUid", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("beforeUid", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("beforeUid", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("beforeUid", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; } @@ -1117,10 +1117,10 @@ private Query afterUid(String uid) { try { urlQueries.put("after_uid", uid); } catch (Exception e) { - throwException("afterUid", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("afterUid", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("afterUid", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("afterUid", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; } @@ -1145,7 +1145,7 @@ public Query skip(int number) { try { urlQueries.put("skip", number); } catch (Exception e) { - throwException("skip", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("skip", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -1169,7 +1169,7 @@ public Query limit(int number) { try { urlQueries.put("limit", number); } catch (Exception e) { - throwException("limit", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("limit", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -1213,10 +1213,10 @@ public Query regex(String key, String regex) { } } catch (Exception e) { - throwException("matches", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("matches", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("matches", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("matches", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; } @@ -1270,10 +1270,10 @@ public Query regex(String key, String regex, String modifiers) { } } catch (Exception e) { - throwException("matches", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("matches", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("matches", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("matches", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; } @@ -1306,10 +1306,10 @@ public Query language(Language language) { } } catch (Exception e) { - throwException("language", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("language", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("language", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("language", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -1336,10 +1336,10 @@ public Query locale(String locale) { } } catch (Exception e) { - throwException("locale", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("locale", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("locale", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("locale", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -1367,10 +1367,10 @@ public Query search(String value) { urlQueries.put("typeahead", value); } } catch (Exception e) { - throwException("value", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("value", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("value", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("value", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; @@ -1422,7 +1422,7 @@ public Query find(QueryResultsCallBack callback) { execQuery(null, callback, false); } else { - throwException("find", SDKConstant.ErrorMessage_FormName, null); + throwException("find", SDKConstant.PLEASE_SET_CONTENT_TYPE_NAME, null); error = new Error(); error.setErrorMessage(errorString); error.setErrors(errorHashMap); @@ -1433,7 +1433,7 @@ public Query find(QueryResultsCallBack callback) { error.setErrors(errorHashMap); } } catch (Exception e) { - throwException("find", SDKConstant.ErrorMessage_JsonNotProper, null); + throwException("find", SDKConstant.PLEASE_PROVIDE_VALID_JSON, null); error = new Error(); error.setErrorMessage(errorString); error.setErrors(errorHashMap); @@ -1483,7 +1483,7 @@ public Query findOne(SingleQueryResultCallback callBack) { } } else { - throwException("find", SDKConstant.ErrorMessage_FormName, null); + throwException("find", SDKConstant.PLEASE_SET_CONTENT_TYPE_NAME, null); error = new Error(); error.setErrorMessage(errorString); error.setErrors(errorHashMap); @@ -1494,7 +1494,7 @@ public Query findOne(SingleQueryResultCallback callBack) { error.setErrors(errorHashMap); } } catch (Exception e) { - throwException("find", SDKConstant.ErrorMessage_JsonNotProper, null); + throwException("find", SDKConstant.PLEASE_PROVIDE_VALID_JSON, null); error = new Error(); error.setErrorMessage(errorString); error.setErrors(errorHashMap); @@ -1574,7 +1574,7 @@ protected void setQueryJson(QueryResultsCallBack callback) { } } catch (Exception e) { - throwException("find", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("find", SDKConstant.PROVIDE_VALID_PARAMS, e); } } @@ -1588,7 +1588,7 @@ protected void execQuery(SingleQueryResultCallback callBack, QueryResultsCallBac ArrayMap headers = getHeader(localHeader); if (headers.size() < 1) { - throwException("find", SDKConstant.ErrorMessage_CalledDefaultMethod, null); + throwException("find", SDKConstant.STACK_FIRST, null); } else { if (headers.containsKey("environment")) { urlQueries.put("environment", headers.get("environment")); @@ -1630,7 +1630,7 @@ protected void execQuery(SingleQueryResultCallback callBack, QueryResultsCallBac } break; case NETWORK_ELSE_CACHE: - if (SDKConstant.isNetworkAvailable) { + if (SDKConstant.IS_NETWORK_AVAILABLE) { fetchFromNetwork(URL, headers, mainJSON, cacheFile.getPath(), callback, callBack); } else { fetchFromCache(cacheFile, callback, callBack); @@ -1651,7 +1651,7 @@ protected void execQuery(SingleQueryResultCallback callBack, QueryResultsCallBac } catch (Exception e) { - throwException("find", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("find", SDKConstant.PROVIDE_VALID_PARAMS, e); } } @@ -1705,14 +1705,14 @@ private void fetchFromCache(File cacheFile, QueryResultsCallBack callback, Singl if (needToSendCall) { error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ENTRY_IS_NOT_PRESENT_IN_CACHE); } else { setCacheModel(cacheFile, callback, callBack); } } else { error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_EntryNotFoundInCache); + error.setErrorMessage(SDKConstant.ENTRY_IS_NOT_PRESENT_IN_CACHE); } if (callback != null && error != null) { @@ -1879,10 +1879,10 @@ public Query addParam(String key, String value) { if (key != null && value != null) { urlQueries.put(key, value); } else { - throwException("and", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("and", SDKConstant.PROVIDE_VALID_PARAMS, null); } } catch (Exception e) { - throwException("and", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("and", SDKConstant.PROVIDE_VALID_PARAMS, e); } return this; } @@ -1939,10 +1939,10 @@ public Query whereIn(String key, Query queryObject) { inQueryObj.put("$in_query", queryObject.queryValueJSON.toString()); queryValueJSON.put(key, inQueryObj); } catch (Exception e) { - throwException("in_query", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("in_query", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("in_query", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("in_query", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; } @@ -1970,10 +1970,10 @@ public Query whereNotIn(String key, Query queryObject) { inQueryObj.put("$nin_query", queryObject.queryValueJSON.toString()); queryValueJSON.put(key, inQueryObj); } catch (Exception e) { - throwException("nin_query", SDKConstant.ErrorMessage_QueryFilterException, e); + throwException("nin_query", SDKConstant.PROVIDE_VALID_PARAMS, e); } } else { - throwException("nin_query", SDKConstant.ErrorMessage_QueryFilterException, null); + throwException("nin_query", SDKConstant.PROVIDE_VALID_PARAMS, null); } return this; } diff --git a/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java b/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java index 1c6a9dd4..c5c43186 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java +++ b/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java @@ -3,20 +3,49 @@ import java.util.ArrayList; /** + * The Contentstack Sdk contain constants. + * * @author contentstack.com, Inc */ public class SDKConstant { + /** + * The constant debug. + */ public static final boolean debug = false; - public static boolean isNetworkAvailable = true; - public static String URLSCHEMA_HTTPS = "https://"; - public static String SDK_VERSION = "3.11.0"; - public final static int NONETWORKCONNECTION = 408; + /** + * The constant IS_NETWORK_AVAILABLE. + */ + public static boolean IS_NETWORK_AVAILABLE = true; + /** + * The constant PROTOCOL. + */ + public static String PROTOCOL = "https://"; + /** + * The constant SDK_VERSION. + */ + public static String SDK_VERSION = "3.12.0"; + /** + * The constant NO_NETWORK_CONNECTION. + */ + public final static int NO_NETWORK_CONNECTION = 408; + /** + * The constant TimeOutDuration. + */ public final static int TimeOutDuration = 30000; // timeout in millisecond + /** + * The constant NumRetry. + */ public final static int NumRetry = 0; + /** + * The constant BackOFMultiplier. + */ public final static int BackOFMultiplier = 0; - //Implemented for single network call cancellation. for class-level network call cancellation. + /** + * The constant cancelledCallController. + */ +//Implemented for single network call cancellation. for class-level network call cancellation. public static ArrayList cancelledCallController = new ArrayList(); /** @@ -25,39 +54,131 @@ public class SDKConstant { */ public static String cacheFolderName; + /** + * The enum Request method. + */ public static enum RequestMethod { - GET, POST, PUT, DELETE + /** + * Get request method. + */ + GET, + /** + * Post request method. + */ + POST, + /** + * Put request method. + */ + PUT, + /** + * Delete request method. + */ + DELETE } + /** + * The enum Call controller. + */ public static enum callController { - + /** + * Query call controller. + */ QUERY, + /** + * Entry call controller. + */ ENTRY, + /** + * Stack call controller. + */ STACK, + /** + * Asset call controller. + */ ASSET, + /** + * Sync call controller. + */ SYNC, + /** + * Content types call controller. + */ CONTENT_TYPES, + /** + * Asset library call controller. + */ ASSET_LIBRARY; } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public final static String ErrorMessage_JsonNotProper = "Please provide valid JSON."; - public final static String ErrorMessage_StackContextIsNull = "Context can not be null."; - public final static String ErrorMessage_StackApiKeyIsNull = "Stack api key can not be null."; - public final static String ErrorMessage_FormName = "Please set contentType name."; - public final static String ErrorMessage_EntryUID = "Please set entry uid."; - public final static String ErrorMessage_Stack_AccessToken_IsNull = "Access token can not be null."; - public final static String ErrorMessage_Stack_Environment_IsNull = "Environment can not be null."; - public final static String ErrorMessage_VolleyNoConnectionError = "Connection error"; - public final static String ErrorMessage_VolleyAuthFailureError = "Authentication Not present."; - public final static String ErrorMessage_VolleyParseError = "Parsing Error."; - public final static String ErrorMessage_VolleyServerError = "Server interaction went wrong, Please try again."; - public final static String ErrorMessage_Default = "Oops! Something went wrong. Please try again."; - public final static String ErrorMessage_NoNetwork = "Network not available."; - public final static String ErrorMessage_CalledDefaultMethod = "You must called Contentstack.stack() first"; - public final static String ErrorMessage_QueryFilterException = "Please provide valid params."; - public final static String ErrorMessage_EntryNotFoundInCache = "ENTRY is not present in cache"; - public final static String ErrorMessage_SavingNetworkCallResponseForCache = "Error while saving network call response."; + /** + * The constant PLEASE_PROVIDE_VALID_JSON. + */ +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + public final static String PLEASE_PROVIDE_VALID_JSON = "Please provide valid JSON."; + /** + * The constant ERROR_MESSAGE_STACK_CONTEXT_IS_NULL. + */ + public final static String ERROR_MESSAGE_STACK_CONTEXT_IS_NULL = "Context can not be null."; + /** + * The constant ERROR_MESSAGE_STACK_API_KEY_IS_NULL. + */ + public final static String ERROR_MESSAGE_STACK_API_KEY_IS_NULL = "Stack api key can not be null."; + /** + * The constant PLEASE_SET_CONTENT_TYPE_NAME. + */ + public final static String PLEASE_SET_CONTENT_TYPE_NAME = "Please set contentType name."; + /** + * The constant PLEASE_SET_ENTRY_UID. + */ + public final static String PLEASE_SET_ENTRY_UID = "Please set entry uid."; + /** + * The constant ERROR_MESSAGE_STACK_ACCESS_TOKEN_IS_NULL. + */ + public final static String ERROR_MESSAGE_STACK_ACCESS_TOKEN_IS_NULL = "Access token can not be null."; + /** + * The constant ERROR_MESSAGE_STACK_ENVIRONMENT_IS_NULL. + */ + public final static String ERROR_MESSAGE_STACK_ENVIRONMENT_IS_NULL = "Environment can not be null."; + /** + * The constant CONNECTION_ERROR. + */ + public final static String CONNECTION_ERROR = "Connection error"; + /** + * The constant AUTHENTICATION_NOT_PRESENT. + */ + public final static String AUTHENTICATION_NOT_PRESENT = "Authentication Not present."; + /** + * The constant PARSING_ERROR. + */ + public final static String PARSING_ERROR = "Parsing Error."; + /** + * The constant TRY_AGAIN. + */ + public final static String TRY_AGAIN = "Server interaction went wrong, Please try again."; + /** + * The constant ERROR_MESSAGE_DEFAULT. + */ + public final static String ERROR_MESSAGE_DEFAULT = "Oops! Something went wrong. Please try again."; + /** + * The constant NOT_AVAILABLE. + */ + public final static String NOT_AVAILABLE = "Network not available."; + /** + * The constant STACK_FIRST. + */ + public final static String STACK_FIRST = "You must called Contentstack.stack() first"; + /** + * The constant PROVIDE_VALID_PARAMS. + */ + public final static String PROVIDE_VALID_PARAMS = "Please provide valid params."; + /** + * The constant ENTRY_IS_NOT_PRESENT_IN_CACHE. + */ + public final static String ENTRY_IS_NOT_PRESENT_IN_CACHE = "ENTRY is not present in cache"; + /** + * The constant NETWORK_CALL_RESPONSE. + */ + public final static String NETWORK_CALL_RESPONSE = "Error while saving network call response."; } diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index d93d6bb4..c8b4d2ff 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -336,7 +336,7 @@ public void getContentTypes(JSONObject params, final ContentTypesCallback callba } catch (Exception e) { Error error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_JsonNotProper); + error.setErrorMessage(SDKConstant.PLEASE_PROVIDE_VALID_JSON); callback.onRequestFail(ResponseType.UNKNOWN, error); } } @@ -612,7 +612,7 @@ public void onCompletion(SyncStack syncStack, Error error) { }); } catch (Exception e) { Error error = new Error(); - error.setErrorMessage(SDKConstant.ErrorMessage_JsonNotProper); + error.setErrorMessage(SDKConstant.PLEASE_PROVIDE_VALID_JSON); callback.onRequestFail(ResponseType.UNKNOWN, error); } } From a9648078730398fdb358f4ce169a4d94fb2ccd1b Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Thu, 27 Apr 2023 17:35:30 +0530 Subject: [PATCH 05/17] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bd572ba..e6b37207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - General code and API document improvements - Breaking changes : PublishType Enums are updated to all CAPS - Kotlin support removed due to build issue +- EntryModel publish_details parsing issue fixed #30 --- From 681d8c64e4944c92f1040a6785d2cac314afb81b Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Thu, 27 Apr 2023 18:04:36 +0530 Subject: [PATCH 06/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- .../contentstack/sdk/CSHttpConnection.java | 3 - .../java/com/contentstack/sdk/Config.java | 3 +- .../java/com/contentstack/sdk/EntryModel.java | 17 ++++-- .../main/java/com/contentstack/sdk/Stack.java | 60 ++++++++++--------- .../java/com/contentstack/sdk/SyncStack.java | 48 +++++++++++++++ 5 files changed, 94 insertions(+), 37 deletions(-) diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java index 77e8786f..0f579ede 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java @@ -252,14 +252,11 @@ public void send() { connectionRequest.onRequestFinished(CSHttpConnection.this); } }, this::generateBuiltError) { - @Override public Map getHeaders() { return headers; } - }; - jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(SDKConstant.TimeOutDuration, SDKConstant.NumRetry, SDKConstant.BackOFMultiplier)); jsonObjectRequest.setShouldCache(false); Contentstack.addToRequestQueue(protocol, jsonObjectRequest, info); diff --git a/contentstack/src/main/java/com/contentstack/sdk/Config.java b/contentstack/src/main/java/com/contentstack/sdk/Config.java index 104507d1..262a6f23 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Config.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Config.java @@ -73,8 +73,7 @@ public void setHost(String hostName) { /** - * Get URL. - * + * Get Host. * *

Example :
*
 iterator = _metadataJSON.keys();
                 _metadata = new WeakHashMap<>();
                 while (iterator.hasNext()) {
@@ -77,17 +84,18 @@ public EntryModel(JSONObject jsonObj, String entryUid, boolean isFromObjectsMode
                 _metadata.put("publish_details", publishDetailsObj);
             }
 
-
             if (jsonObject != null && jsonObject.has("_owner") && (jsonObject.opt("_owner") != null) && (!jsonObject.opt("_owner").toString().equalsIgnoreCase("null"))) {
                 JSONObject ownerObject = jsonObject.optJSONObject("_owner");
+                assert ownerObject != null;
                 if (ownerObject.has("email") && ownerObject.opt("email") != null) {
                     ownerEmailId = (String) ownerObject.opt("email");
                 }
 
                 if (ownerObject.has("uid") && ownerObject.opt("uid") != null) {
-                    ownerUid = ownerObject.opt("uid").toString();
+                    ownerUid = Objects.requireNonNull(ownerObject.opt("uid")).toString();
                 }
                 JSONObject owner = jsonObject.optJSONObject("_owner");
+                assert owner != null;
                 Iterator iterator = owner.keys();
                 ownerMap = new WeakHashMap<>();
                 while (iterator.hasNext()) {
@@ -96,6 +104,7 @@ public EntryModel(JSONObject jsonObj, String entryUid, boolean isFromObjectsMode
                 }
             }
 
+            assert jsonObject != null;
             tagsArray = (JSONArray) jsonObject.opt("tags");
             if (tagsArray != null && tagsArray.length() > 0) {
                 int count = tagsArray.length();
diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java
index c8b4d2ff..412538f9 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java
@@ -84,27 +84,6 @@ protected void setConfig(Config config) {
 
     }
 
-    /**
-     * @param syncCallBack returns callback for sync result.
-     *                     

- *

- * The Sync request performs a complete sync of your app data. - * 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. - *

- */ - - public void sync(SyncResultCallBack syncCallBack) { - try { - syncParams = new JSONObject(); - syncParams.put("init", true); - } catch (JSONException e) { - Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); - } - this.requestSync(syncCallBack); - - } /** * Represents a {@link ContentType}.
@@ -349,6 +328,32 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap } } + + /** + * @param syncCallBack returns callback for sync result. + *

+ *

+ * The Sync request performs a complete sync of your app data. + * It returns all the published entries and assets of the specified stack in response. + * The response also contains a sync token, which you need to store, + * since this token is used to get subsequent delta updates later. + * + * + * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); + * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} + * + */ + + public void sync(SyncResultCallBack syncCallBack) { + try { + syncParams = new JSONObject(); + syncParams.put("init", true); + } catch (JSONException e) { + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); + } + this.requestSync(syncCallBack); + } + /** * @param paginationToken If the response is paginated, use the pagination token under this parameter. * @param syncCallBack returns callback for sync result @@ -362,9 +367,9 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap * In such cases, this token can be used to restart the sync process from where it was interrupted. * * + * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} * - * * */ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncCallBack) { @@ -386,7 +391,7 @@ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncC * and the details of the content that was deleted or updated. *

Example :
*

-     *                                             
+ * */ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { try { @@ -407,8 +412,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); @@ -467,7 +472,6 @@ public void syncLocale(Language language, SyncResultCallBack syncCallBack) { } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } - this.requestSync(syncCallBack); } @@ -501,7 +505,7 @@ public void syncLocale(@NotNull String localeCode, SyncResultCallBack syncCallBa * If you do not specify any value, it will bring all published entries and published assets. *

* - * stackInstance.syncPublishType(Stack.PublishType.entry_published, new SyncResultCallBack()) { } + * stackInstance.syncPublishType(Stack.PublishType.ENTRY_PUBLISHED, new SyncResultCallBack()) { } * * * @@ -554,7 +558,7 @@ public void sync(String contentType, Date fromDate, Language language, PublishTy syncParams.put("type", type.toString().toLowerCase()); syncParams.put("locale", this.localeCode); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } this.requestSync(syncCallBack); } diff --git a/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java b/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java index 9c867fc2..96551bb4 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/SyncStack.java @@ -6,6 +6,9 @@ import java.util.ArrayList; +/** + * The type Sync stack. + */ public class SyncStack { private static final String TAG = SyncStack.class.getSimpleName(); @@ -19,38 +22,83 @@ public class SyncStack { private ArrayList syncItems; + /** + * Gets url. + * + * @return the url + */ public String getURL() { return this.URL; } + /** + * Gets json response. + * + * @return the json response + */ public JSONObject getJSONResponse() { return this.receiveJson; } + /** + * Gets count. + * + * @return the count + */ public int getCount() { return this.count; } + /** + * Gets limit. + * + * @return the limit + */ public int getLimit() { return this.limit; } + /** + * Gets skip. + * + * @return the skip + */ public int getSkip() { return this.skip; } + /** + * Gets pagination token. + * + * @return the pagination token + */ public String getPaginationToken() { return this.pagination_token; } + /** + * Gets sync token. + * + * @return the sync token + */ public String getSyncToken() { return this.sync_token; } + /** + * Gets items. + * + * @return the items + */ public ArrayList getItems() { return this.syncItems; } + /** + * Sets json. + * + * @param jsonobject the jsonobject + */ protected void setJSON(JSONObject jsonobject) { if (jsonobject != null) { From d03ea6fd79e5a80392dd388e6014417cfe436b45 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 2 May 2023 15:31:29 +0530 Subject: [PATCH 07/17] feat/CS-37836-azure-eu-and-include-metadata CS-37836 Azure-EU, include-metadata and general improvements --- contentstack/build.gradle | 36 +- .../sdk/AssetInstrumentedTest.java | 265 ------- .../sdk/EntryInstrumentedTest.java | 334 --------- .../sdk/ExampleInstrumentedTest.java | 34 + .../sdk/QueryInstrumentedTest.java | 653 ------------------ .../sdk/SyncInstrumentedTest.java | 238 ------- .../sdk/TransformInstrumentedTest.java | 239 ------- .../src/azure-eu/java/AzureEUTest.java | 20 + .../src/azure-na/java/AzureNATest.java | 20 + .../src/eu/java/EUInstrumentedTest.java | 20 + .../main/java/com/contentstack/sdk/Asset.java | 6 - .../java/com/contentstack/sdk/AssetModel.java | 2 +- .../com/contentstack/sdk/AssetsModel.java | 5 - .../contentstack/sdk/CSConnectionRequest.java | 21 +- .../contentstack/sdk/CSHttpConnection.java | 19 +- .../java/com/contentstack/sdk/CSUtil.java | 19 +- .../java/com/contentstack/sdk/ClearCache.java | 4 - .../java/com/contentstack/sdk/Config.java | 13 +- .../contentstack/sdk/ConnectionStatus.java | 2 +- .../com/contentstack/sdk/ContentType.java | 1 - .../contentstack/sdk/ContentTypesModel.java | 6 +- .../com/contentstack/sdk/Contentstack.java | 177 ++--- .../com/contentstack/sdk/SDKConstant.java | 138 +--- .../java/com/contentstack/sdk/SDKUtil.java | 24 +- .../main/java/com/contentstack/sdk/Stack.java | 115 +-- .../java/com/contentstack/sdk/AssetTest.java | 24 - .../com/contentstack/sdk/ExampleUnitTest.java | 30 + scripts/publish-module.gradle | 52 +- scripts/publish-root.gradle | 30 +- 29 files changed, 361 insertions(+), 2186 deletions(-) delete mode 100644 contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java delete mode 100644 contentstack/src/androidTest/java/com/contentstack/sdk/EntryInstrumentedTest.java create mode 100644 contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java delete mode 100644 contentstack/src/androidTest/java/com/contentstack/sdk/QueryInstrumentedTest.java delete mode 100644 contentstack/src/androidTest/java/com/contentstack/sdk/SyncInstrumentedTest.java delete mode 100644 contentstack/src/androidTest/java/com/contentstack/sdk/TransformInstrumentedTest.java create mode 100644 contentstack/src/azure-eu/java/AzureEUTest.java create mode 100644 contentstack/src/azure-na/java/AzureNATest.java create mode 100644 contentstack/src/eu/java/EUInstrumentedTest.java delete mode 100644 contentstack/src/test/java/com/contentstack/sdk/AssetTest.java create mode 100644 contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java diff --git a/contentstack/build.gradle b/contentstack/build.gradle index f38e31e9..6dedc205 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -1,27 +1,8 @@ apply plugin: 'com.android.library' apply plugin: 'jacoco' -ext { - PUBLISH_GROUP_ID = 'com.contentstack.sdk' - PUBLISH_ARTIFACT_ID = 'android' - PUBLISH_VERSION = '3.12.0-SNAPSHOT' - PUBLISH_DESCRIPTION = 'The Content Delivery SDK is used to retrieve content from your Contentstack account and deliver it to your web or mobile properties.' - PUBLISH_URL = 'https://github.com/contentstack/contentstack-android' - PUBLISH_LICENSE_NAME = 'MIT License' - PUBLISH_LICENSE_URL = 'https://github.com/contentstack/contentstack-android/blob/master/LICENSE' - PUBLISH_DEVELOPER_ID = 'ishaileshmishra' - PUBLISH_DEVELOPER_NAME = 'Shailesh Mishra' - PUBLISH_DEVELOPER_EMAIL = 'shailesh.mishra@contentstack.com' - PUBLISH_SCM_CONNECTION = 'scm:git@github.com:contentstack/contentstack-android' - PUBLISH_SCM_DEVELOPER_CONNECTION = 'scm:git@github.com:contentstack/contentstack-android' - PUBLISH_SCM_URL = 'https://github.com/contentstack/contentstack-android/tree/master' -} - apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" -def localProperties = new Properties() -localProperties.load(new FileInputStream(rootProject.file("local.properties"))) - android { namespace 'com.contentstack.sdk' compileSdk 33 @@ -34,11 +15,14 @@ android { multiDexEnabled true vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + testHandleProfiling true + testFunctionalTest true } buildTypes { + def localProperties = new Properties() + localProperties.load(new FileInputStream(rootProject.file("local.properties"))) debug { - minifyEnabled false - debuggable true + debuggable false testCoverageEnabled true buildConfigField "String", "host", localProperties['host'] buildConfigField "String", "APIKey", localProperties['APIKey'] @@ -49,6 +33,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } release { + debuggable false minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' buildConfigField "String", "host", localProperties['host'] @@ -79,11 +64,8 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.android.volley:volley:1.2.1' - testImplementation 'junit:junit:5.9.2' - testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1' + implementation 'androidx.test:core:1.5.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - - androidTestImplementation ("androidx.test.espresso:espresso-contrib:3.5.1") { - exclude module: "protobuf-lite" - } } \ No newline at end of file diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java deleted file mode 100644 index cf4f4467..00000000 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetInstrumentedTest.java +++ /dev/null @@ -1,265 +0,0 @@ -package com.contentstack.sdk; - -import static junit.framework.Assert.assertTrue; -import static junit.framework.TestCase.assertEquals; - -import android.content.Context; -import android.util.Log; - -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; -import androidx.test.platform.app.InstrumentationRegistry; - -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.junit.runners.MethodSorters; - -import java.util.List; - - -@RunWith(AndroidJUnit4ClassRunner.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class AssetInstrumentedTest { - - private static String assetUid = BuildConfig.assetUID; - private static Stack stack; - private final String TAG = AssetInstrumentedTest.class.getSimpleName(); - - @BeforeClass - public static void oneTimeSetUp() throws Exception { - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - 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); - stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); - } - - - @Test() - public void testAGetAllAssetsToSetAssetUid() { - final AssetLibrary assetLibrary = stack.assetLibrary(); - assetLibrary.fetchAll(new FetchAssetsCallback() { - @Override - public void onCompletion(ResponseType responseType, List assets, Error error) { - if (error == null) { - assetUid = assets.get(0).getAssetUid(); - } - } - }); - - } - - @Test - public void test_B_VerifyAssetUID() { - - final Asset asset = stack.asset(assetUid); - asset.fetch(new FetchResultCallback() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - // Success Block. - Log.d(TAG, "response: " + asset.getAssetUid()); - assertEquals(assetUid, asset.getAssetUid()); - } - } - }); - } - - @Test - public void test_C_Asset_fetch() { - final Asset asset = stack.asset(assetUid); - asset.fetch(new FetchResultCallback() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - assertEquals(BuildConfig.assetUID, asset.getAssetUid()); - assertEquals("image/jpeg", asset.getFileType()); - assertEquals("phoenix2.jpg", asset.getFileName()); - assertEquals("482141", asset.getFileSize()); - } else { - assertEquals(105, error.getErrorCode()); - } - } - }); - } - - @Test - public void test_D_AssetLibrary_fetch() { - final AssetLibrary assetLibrary = stack.assetLibrary(); - assetLibrary.fetchAll(new FetchAssetsCallback() { - @Override - public void onCompletion(ResponseType responseType, List assets, Error error) { - if (error == null) { - assets.forEach(asset -> { - Log.d(TAG, "----Test--Asset-D--Success----" + asset.toJSON()); - Log.d(TAG, "----Test--Asset-D--Success----" + asset.getFileType()); - Log.d(TAG, "----Test--Asset-D--Success----" + asset.getCreatedBy()); - Log.d(TAG, "----Test--Asset-D--Success----" + asset.getUpdatedBy()); - Log.d(TAG, "----Test--Asset-D--Success----" + asset.getFileName()); - Log.d(TAG, "----Test--Asset-D--Success----" + asset.getFileSize()); - Log.d(TAG, "----Test--Asset-D--Success----" + asset.getAssetUid()); - Log.d(TAG, "----Test--Asset-D--Success----" + asset.getUrl()); - }); - } - } - }); - } - - @Test - public void test_E_AssetLibrary_includeCount_fetch() { - final AssetLibrary assetLibrary = stack.assetLibrary(); - assetLibrary.includeCount(); - assetLibrary.fetchAll(new FetchAssetsCallback() { - @Override - public void onCompletion(ResponseType responseType, List assets, Error error) { - if (error == null) { - assertEquals(16, assetLibrary.getCount()); - } - } - }); - } - - @Test - public void test_F_AssetLibrary_includeRelativeUrl_fetch() { - final AssetLibrary assetLibrary = stack.assetLibrary(); - assetLibrary.includeRelativeUrl(); - assetLibrary.fetchAll(new FetchAssetsCallback() { - public void onCompletion(ResponseType responseType, List assets, Error error) { - if (error == null) { - assertTrue(assets.get(0).getUrl().contains("phoenix2.jpg")); - } - } - }); - } - - @Test - public void test_G_Include_Dimension() { - final Asset asset = stack.asset(assetUid); - asset.includeDimension().fetch(new FetchResultCallback() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - Log.d(TAG, asset.getAssetUid()); - assertEquals(assetUid, asset.getAssetUid()); - } - } - }); - } - - - @Test - public void test_H_include_fallback() { - final Asset asset = stack.asset(assetUid); - asset.includeFallback().fetch(new FetchResultCallback() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - Log.d(TAG, asset.getAssetUid()); - assertEquals(assetUid, asset.getAssetUid()); - } - } - }); - } - - @Test - public void setStackInstance() { - } - - @Test - public void configure() { - } - - @Test - public void setHeader() { - } - - @Test - public void removeHeader() { - } - - @Test - public void setUid() { - } - - @Test - public void getAssetUid() { - } - - @Test - public void getFileType() { - } - - @Test - public void getFileSize() { - } - - @Test - public void getFileName() { - } - - @Test - public void getUrl() { - } - - @Test - public void toJSON() { - } - - @Test - public void getCreateAt() { - } - - @Test - public void getCreatedBy() { - } - - @Test - public void getUpdateAt() { - } - - @Test - public void getUpdatedBy() { - } - - @Test - public void getDeleteAt() { - } - - @Test - public void getDeletedBy() { - } - - @Test - public void getTags() { - } - - @Test - public void setCachePolicy() { - } - - @Test - public void fetch() { - } - - @Test - public void setTags() { - } - - @Test - public void addParam() { - } - - @Test - public void includeDimension() { - } - - @Test - public void includeFallback() { - } - -} diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/EntryInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/EntryInstrumentedTest.java deleted file mode 100644 index 4d57efde..00000000 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/EntryInstrumentedTest.java +++ /dev/null @@ -1,334 +0,0 @@ -package com.contentstack.sdk; - -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertTrue; - -import android.content.Context; -import android.util.Log; - -import androidx.test.platform.app.InstrumentationRegistry; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; - - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class EntryInstrumentedTest { - - private final static String TAG = EntryInstrumentedTest.class.getSimpleName(); - private static String entryUID; - private static final String CONTENT_TYPE_UID = BuildConfig.contentTypeUID; - private static CountDownLatch latch; - private static Stack stack; - - - @BeforeClass - public static void oneTimeSetUp() throws Exception { - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - - Config config = new Config(); - String DEFAULT_HOST = BuildConfig.host; - config.setHost(DEFAULT_HOST); - stack = Contentstack.stack(appContext, BuildConfig.APIKey, BuildConfig.deliveryToken, BuildConfig.environment, config); - - latch = new CountDownLatch(1); - Log.d(TAG, "test started..."); - } - - @AfterClass - public static void oneTimeTearDown() { - // one-time cleanup code - Log.d(TAG, "When all the test cases of class finishes..."); - Log.d(TAG, "Total testcase: " + latch.getCount()); - } - - @Before - public void setUp() { - latch = new CountDownLatch(1); - } - - - @After - public void tearDown() { - Log.d(TAG, "Runs after every testcase completes."); - latch.countDown(); - } - - - @Test - public void testCustomHeader() { - final Query query = stack.contentType(CONTENT_TYPE_UID).query(); - query.setHeader("customHeaderKey", "customHeaderValue"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - entryUID = queryresult.getResultObjects().get(15).getUid(); - } - } - }); - } - - @Test - public void test_01_findAllEntries() { - final Query query = stack.contentType(CONTENT_TYPE_UID).query(); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - entryUID = queryresult.getResultObjects().get(15).getUid(); - } - } - }); - } - - @Test - public void test_02_only_fetch() { - final Entry entry = stack.contentType(CONTENT_TYPE_UID).entry(entryUID); - entry.only(new String[]{"price"}); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - assertEquals(786, entry.toJSON().opt("price")); - } - } - }); - } - - @Test - public void test_03_except_fetch() { - final Entry entry = stack.contentType(CONTENT_TYPE_UID).entry(entryUID); - entry.except(new String[]{"title"}); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - Log.e(TAG, entry.toJSON().optString("title")); - } else { - Log.e(TAG, error.getErrorMessage()); - } - } - }); - } - - @Test - public void test_04_includeReference_fetch() { - final Entry entry = stack.contentType(CONTENT_TYPE_UID).entry(entryUID); - entry.includeReference("category"); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - JSONArray categoryArray = entry.getJSONArray("category"); - - try { - for (int index = 0; index < categoryArray.length(); index++) { - JSONObject array = (JSONObject) categoryArray.get(index); - assertTrue(array.toString().contains("_content_type_uid")); - } - } catch (Exception e) { - Log.e(TAG, e.getLocalizedMessage()); - } - - } - } - }); - } - - @Test - public void test_05_includeReferenceOnly_fetch() { - final Entry entry = stack.contentType(CONTENT_TYPE_UID).entry(entryUID); - ArrayList strings = new ArrayList<>(); - strings.add("title"); - strings.add("orange"); - strings.add("mango"); - entry.onlyWithReferenceUid(strings, "category"); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - assertEquals("laptop", entry.toJSON().optString("title")); - } - } - }); - - } - - - @Test - public void test_06_includeReferenceExcept_fetch() throws InterruptedException { - final Entry entry = stack.contentType(CONTENT_TYPE_UID).entry(entryUID); - ArrayList strings = new ArrayList<>(); - strings.add("color"); - strings.add("price_in_usd"); - entry.exceptWithReferenceUid(strings, "category"); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - latch.countDown(); - } else { - latch.countDown(); - } - - } - }); - latch.await(); - - } - - - @Test - public void test_07_getMarkdown_fetch() throws InterruptedException { - - final Entry entry = stack.contentType("user").entry(entryUID); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - latch.countDown(); - } else { - latch.countDown(); - } - } - }); - latch.await(); - } - - - @Test - public void test_08_get() throws InterruptedException { - final Entry entry = stack.contentType("user").entry(entryUID); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - latch.countDown(); - } else { - latch.countDown(); - } - } - }); - latch.await(); - } - - - @Test - public void test_09_getParam() throws InterruptedException { - final Entry entry = stack.contentType("user").entry(entryUID); - entry.addParam("include_dimensions", "true"); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - latch.countDown(); - } else { - latch.countDown(); - } - } - }); - latch.await(); - } - - - @Test - public void test_10_IncludeReferenceContentTypeUID() throws InterruptedException { - final Entry entry = stack.contentType("user").entry(entryUID); - entry.includeReferenceContentTypeUID(); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - JSONObject jsonResult = entry.toJSON(); - try { - JSONArray cartList = (JSONArray) jsonResult.get("cart"); - Object whatTYPE = cartList.get(0); - if (whatTYPE instanceof JSONObject) { - assertTrue(true); - } - } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); - } - latch.countDown(); - } else { - latch.countDown(); - } - } - }); - latch.await(); - - } - - - @Test - public void test_11_Locale() throws InterruptedException { - final Entry entry = stack.contentType("user").entry(entryUID); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - String checkResp = entry.getLocale(); - Log.e(TAG, checkResp); - latch.countDown(); - } else { - latch.countDown(); - } - - } - }); - latch.await(); - } - - @Test - public void test_12_entry_except() throws InterruptedException { - final Entry entry = stack.contentType("user").entry(entryUID); - String[] allValues = {"color", "price_in_usd"}; - entry.except(allValues); - entry.fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - String checkResp = entry.getLocale(); - Log.d(TAG, checkResp); - latch.countDown(); - } else { - latch.countDown(); - } - } - }); - latch.await(); - } - - @Test - public void test_13_entry_include_embedded_items_unit_test() throws InterruptedException { - - final Entry entry = stack.contentType("user").entry(entryUID); - entry.includeEmbeddedItems().fetch(new EntryResultCallBack() { - @Override - public void onCompletion(ResponseType responseType, Error error) { - if (error == null) { - String checkResp = entry.getLocale(); - Log.d(TAG, checkResp); - } - boolean hasEmbeddedItemKey = entry.otherPostJSON.has("include_embedded_items[]"); - Assert.assertTrue(hasEmbeddedItemKey); - latch.countDown(); - } - }); - latch.await(); - } - -} diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java new file mode 100644 index 00000000..3d3ac705 --- /dev/null +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java @@ -0,0 +1,34 @@ +package com.contentstack.sdk; + +import static org.junit.Assert.assertEquals; + +import android.content.Context; + +import androidx.test.core.app.ApplicationProvider; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("contentstack.sdk.test", appContext.getPackageName()); + } + + @Test + public void initSDK() throws Exception { + Context ctx = ApplicationProvider.getApplicationContext(); + Stack stack = Contentstack.stack(ctx, "", "", ""); + stack.sync(new SyncResultCallBack() { + @Override + public void onCompletion(SyncStack syncStack, Error error) { + + } + }); + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/QueryInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/QueryInstrumentedTest.java deleted file mode 100644 index 286afb1b..00000000 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/QueryInstrumentedTest.java +++ /dev/null @@ -1,653 +0,0 @@ -package com.contentstack.sdk; - -import static junit.framework.TestCase.assertEquals; - -import android.content.Context; -import android.util.Log; - -import androidx.test.platform.app.InstrumentationRegistry; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - - -public class QueryInstrumentedTest { - - private static final String TAG = QueryInstrumentedTest.class.getSimpleName(); - private static Stack stack; - private static Query query; - private static final String contentTypeUID = BuildConfig.contentTypeUID; - - @BeforeClass - public static void oneTimeSetUp() throws Exception { - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - - 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); - stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); - query = stack.contentType(contentTypeUID).query(); - } - - - @Before - public void setUp() { - query = stack.contentType(contentTypeUID).query(); - } - - - @Test - public void test_01_fetchAllEntries() { - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List listOfEntries = queryresult.getResultObjects(); - } - } - }); - } - - @Test() - public void test_03_fetchSingleNonExistingEntry() { - Query query = stack.contentType("categories").query(); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List listOfEntries = queryresult.getResultObjects(); - } - } - }); - } - - @Test - public void test_04_fetchEntryWithIncludeReference() { - query.includeReference("category"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List listOfEntries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_05_fetchEntryNotContainedInField() { - String[] containArray = new String[]{"Roti Maker", "kids dress"}; - query.notContainedIn("title", containArray); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - - if (error == null) { - List entries = queryresult.getResultObjects(); - int price = entries.get(0).toJSON().optInt("price"); - assertEquals(45, price); - } - } - }); - } - - - @Test - public void test_07_fetchEntryNotEqualToField() { - query.notEqualTo("title", "yellow t shirt"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - entries.forEach(entry -> Log.i(TAG, entry.getString("title"))); - } - } - }); - } - - - @Test - public void test_08_fetchEntryGreaterThanEqualToField() { - query.greaterThanOrEqualTo("price", 90); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - entries.forEach(entry -> { - //og.i(TAG,entry.getString("price")); - }); - } - } - }); - } - - - @Test - public void test_09_fetchEntryGreaterThanField() { - query.greaterThan("price", 90); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - entries.forEach(entry -> { - //Log.i(TAG,entry.getString("price"); - }); - } - } - }); - } - - - @Test - public void test_10_fetchEntryLessThanEqualField() { - query.lessThanOrEqualTo("price", 90); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - int price = entries.get(0).toJSON().optInt("price"); - assertEquals(45, price); - } - } - }); - } - - - @Test - public void test_11_fetchEntryLessThanField() { - query.lessThan("price", "90"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List resp = queryresult.getResultObjects(); - resp.forEach(entry -> { - Log.i(TAG, "Is price less than 90..? " + entry.get("price")); - }); - } - } - }); - } - - - @Test - public void test_12_fetchEntriesWithOr() { - - ContentType ct = stack.contentType(contentTypeUID); - Query orQuery = ct.query(); - - Query query = ct.query(); - query.lessThan("price", 90); - - Query subQuery = ct.query(); - subQuery.containedIn("discount", new Integer[]{20, 45}); - - ArrayList array = new ArrayList(); - array.add(query); - array.add(subQuery); - orQuery.or(array); - - orQuery.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List listOfEntries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_13_fetchEntriesWithAnd() { - - ContentType ct = stack.contentType(contentTypeUID); - Query orQuery = ct.query(); - - Query query = ct.query(); - query.lessThan("price", 90); - - Query subQuery = ct.query(); - subQuery.containedIn("discount", new Integer[]{20, 45}); - - ArrayList array = new ArrayList(); - array.add(query); - array.add(subQuery); - - orQuery.and(array); - orQuery.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List listOfEntries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_14_addQuery() { - query.addQuery("limit", "8"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List listOfEntries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_15_removeQueryFromQuery() { - query.addQuery("limit", "8"); - query.removeQuery("limit"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List listOfEntries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_16_includeSchema() { - query.includeContentType(); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - JSONObject contentTypeObj = queryresult.getContentType(); - } - } - }); - } - - - @Test - public void test_17_search() { - query.search("dress"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - for (Entry entry : entries) { - JSONObject jsonObject = entry.toJSON(); - Iterator iter = jsonObject.keys(); - while (iter.hasNext()) { - String key = iter.next(); - try { - Object value = jsonObject.opt(key); - if (value instanceof String && ((String) value).contains("dress")) - Log.i(TAG, value.toString()); - } catch (Exception e) { - Log.i(TAG, "----------------setQueryJson" + e.toString()); - } - } - } - } - } - }); - } - - - @Test - public void test_18_ascending() { - query.ascending("title"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - for (Entry entry : entries) { - Log.i(TAG, entry.getString("title")); - } - } - } - }); - } - - - @Test - public void test_19_descending() { - query.descending("title"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - for (Entry entry : entries) { - Log.i(TAG, entry.getString("title")); - } - } - } - }); - } - - - @Test - public void test_20_limit() { - query.limit(3); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - for (Entry entry : entries) { - Log.i(TAG, " entry = [" + entry.getString("title") + "]"); - } - } - } - }); - } - - - @Test - public void test_21_skip() { - query.skip(3); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_22_only() { - query.only(new String[]{"price"}); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_23_except() { - query.locale("en-eu"); - query.except(new String[]{"price", "chutiya"}); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_24_count() { - query.count(); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - int count = queryresult.getCount(); - } - } - }); - } - - - @Test - public void test_25_regex() { - query.regex("title", "lap*", "i"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_26_exist() { - query.exists("title"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_27_notExist() { - query.notExists("price1"); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - int entryCount = queryresult.getCount(); - } - } - }); - - - } - - - @Test - public void test_28_tags() { - query.tags(new String[]{"pink"}); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - } - } - }); - - - } - - - @Test - public void test_29_language() { - query.language(Language.ENGLISH_UNITED_KINGDOM); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - } - } - }); - - - } - - - @Test - public void test_33_findOne() { - query.includeCount(); - query.where("in_stock", true); - query.findOne(new SingleQueryResultCallback() { - @Override - public void onCompletion(ResponseType responseType, Entry entry, Error error) { - if (error == null) { - System.out.println("entry: " + entry); - } - } - }); - } - - - @Test - public void test_34_complexFind() { - query.notEqualTo("title", "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.*************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.*************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.*************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.*************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.************************************Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.*******"); - query.includeCount(); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - List entries = queryresult.getResultObjects(); - } - } - }); - } - - - @Test - public void test_35_includeSchema() { - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - JSONArray result; - if (error == null) { - result = queryresult.getSchema(); - } - } - }); - } - - - @Test - public void test_36_includeContentType() { - query.includeContentType(); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - JSONObject entries = queryresult.getContentType(); - } - } - }); - } - - - @Test - public void test_38_include_content_type() { - query.includeContentType(); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - JSONObject result; - if (error == null) { - result = queryresult.getContentType(); - } - } - }); - } - - - @Test - public void test_39_include_content_type() { - query.includeContentType(); - query.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - JSONObject entries = queryresult.getContentType(); - } - } - }); - } - - - @Test - public void test_40_WithoutIncludeFallback() { - Query fallbackQuery = stack.contentType("categories").query(); - fallbackQuery.locale("hi-in"); - fallbackQuery.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - assertEquals(0, queryresult.getResultObjects().size()); - fallbackQuery.includeFallback().locale("hi-in"); - fallbackQuery.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - assertEquals(0, queryresult.getResultObjects().size()); - } - }); - } - } - }); - } - - @Test - public void test_40_WithIncludeFallback() { - Query fallbackQuery = stack.contentType("categories").query(); - fallbackQuery.locale("hi-in"); - fallbackQuery.find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - assertEquals(0, queryresult.getResultObjects().size()); - } - } - }); - } - - - @Test - public void test_41_entry_include_embedded_items_unit_test() { - - final Query query = stack.contentType("user").query(); - query.includeEmbeddedItems().find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - Entry checkResp = queryresult.getResultObjects().get(0); - Log.d(TAG, checkResp.toString()); - } - } - }); - } - - - @Test - public void query_include_embedded_items_unit_test() throws Exception { - final Query query = stack.contentType("testembededobjects").query(); - query.includeEmbeddedItems().find(new QueryResultsCallBack() { - @Override - public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) { - if (error == null) { - Entry checkResp = queryresult.getResultObjects().get(0); - Log.d(TAG, queryresult.getResultObjects().toString()); - } - } - }); - } - - -} \ No newline at end of file diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/SyncInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/SyncInstrumentedTest.java deleted file mode 100644 index 2d77d28c..00000000 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/SyncInstrumentedTest.java +++ /dev/null @@ -1,238 +0,0 @@ -package com.contentstack.sdk; - -import android.content.Context; -import android.util.Log; - -import androidx.test.platform.app.InstrumentationRegistry; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.LinkedHashMap; -import java.util.concurrent.CountDownLatch; - - -public class SyncInstrumentedTest { - - static final String TAG = SyncInstrumentedTest.class.getSimpleName(); - private static CountDownLatch latch; - private static Stack stack; - private final LinkedHashMap imageParams = new LinkedHashMap<>(); - private final String IMAGE_URL = "https://images.contentstack.io/v3/assets/download"; - - - @BeforeClass - public static void oneTimeSetUp() throws Exception { - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - - 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); - stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); - - latch = new CountDownLatch(1); - } - - @Before - public void setUp() { - latch = new CountDownLatch(1); - } - - - @Test - public void test_00_fetchAllImageTransformation() { - - imageParams.put("auto", "webp"); - imageParams.put("quality", 200); - imageParams.put("width", 100); - imageParams.put("height", 50); - imageParams.put("format", "png"); - imageParams.put("crop", "3:5"); - imageParams.put("trim", "20,20,20,20"); - imageParams.put("disable", "upscale"); - imageParams.put("pad", "10,10,10,10"); - imageParams.put("bg-color", "#FFFFFF"); - imageParams.put("dpr", 20); - imageParams.put("canvas", "3:5"); - imageParams.put("orient", "l"); - - String image_url = stack.ImageTransform(IMAGE_URL, imageParams); - int counter = 0; - if (image_url.contains("?")) { - String[] imgKeys = image_url.split("\\?"); - String rightUrl = imgKeys[1]; - String[] getAllPairs = rightUrl.split("\\&"); - counter = 0; - if (imageParams.size() > 0) { - for (int i = 0; i < imageParams.size(); i++) { - String keyValueParis = getAllPairs[i]; - Log.i(TAG, "pairs:--> " + keyValueParis); - ++counter; - } - } - } else { - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - - if (counter == imageParams.size()) { - latch.countDown(); - Log.i(TAG, "Testcases Passed"); - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - } - - - @Test - public void test_01_fetchAllImageTransformation() { - - imageParams.put("auto", "webp"); - imageParams.put("quality", 200); - imageParams.put("width", 100); - imageParams.put("height", 50); - imageParams.put("format", "png"); - imageParams.put("crop", "3:5"); - - String image_url = stack.ImageTransform(IMAGE_URL, imageParams); - int counter = 0; - /* check url contains "?" */ - if (image_url.contains("?")) { - String[] imgKeys = image_url.split("\\?"); - String rightUrl = imgKeys[1]; - String[] getAllPairs = rightUrl.split("\\&"); - counter = 0; - if (imageParams.size() > 0) { - for (int i = 0; i < imageParams.size(); i++) { - String keyValueParis = getAllPairs[i]; - Log.i(TAG, "pairs:--> " + keyValueParis); - ++counter; - } - } - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - - if (counter == imageParams.size()) { - latch.countDown(); - Log.i(TAG, "Testcases Passed"); - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - } - - - @Test - public void test_02_fetchAllImageTransformation() { - imageParams.put("trim", "20,20,20,20"); - imageParams.put("disable", "upscale"); - imageParams.put("pad", "10,10,10,10"); - imageParams.put("bg-color", "#FFFFFF"); - imageParams.put("dpr", 20); - imageParams.put("canvas", "3:5"); - imageParams.put("orient", "l"); - String image_url = stack.ImageTransform(IMAGE_URL, imageParams); - int counter = 0; - /* check url contains "?" */ - if (image_url.contains("?")) { - String[] imgKeys = image_url.split("\\?"); - String rightUrl = imgKeys[1]; - String[] getAllPairs = rightUrl.split("\\&"); - if (imageParams.size() > 0) { - for (int i = 0; i < imageParams.size(); i++) { - String keyValueParis = getAllPairs[i]; - Log.i(TAG, "pairs:--> " + keyValueParis); - ++counter; - } - } - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - - if (counter == imageParams.size()) { - latch.countDown(); - Log.i(TAG, "Testcases Passed"); - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - } - - - @Test - public void test_03_fetchAllImageTransformation() { - - - imageParams.put("trim", "20,20,20,20"); - imageParams.put("disable", "upscale"); - imageParams.put("canvas", "3:5"); - imageParams.put("orient", "l"); - - String image_url = stack.ImageTransform(IMAGE_URL, imageParams); - int counter = 0; - /* check url contains "?" */ - if (image_url.contains("?")) { - String[] imgKeys = image_url.split("\\?"); - String rightUrl = imgKeys[1]; - String[] getAllPairs = rightUrl.split("\\&"); - counter = 0; - if (imageParams.size() > 0) { - for (int i = 0; i < imageParams.size(); i++) { - String keyValueParis = getAllPairs[i]; - Log.i(TAG, "pairs:--> " + keyValueParis); - ++counter; - } - } - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - - if (counter == imageParams.size()) { - latch.countDown(); - Log.i(TAG, "Testcases Passed"); - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - } -} diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/TransformInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/TransformInstrumentedTest.java deleted file mode 100644 index af47f4c1..00000000 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/TransformInstrumentedTest.java +++ /dev/null @@ -1,239 +0,0 @@ -package com.contentstack.sdk; - -import android.content.Context; -import android.util.Log; - -import androidx.test.platform.app.InstrumentationRegistry; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.LinkedHashMap; -import java.util.concurrent.CountDownLatch; - - -public class TransformInstrumentedTest { - - static final String TAG = TransformInstrumentedTest.class.getSimpleName(); - private static CountDownLatch latch; - private static Stack stack; - private final LinkedHashMap imageParams = new LinkedHashMap<>(); - private final String IMAGE_URL = "https://images.contentstack.io/v3/assets/download"; - - - @BeforeClass - public static void oneTimeSetUp() throws Exception { - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - - 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); - stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config); - - latch = new CountDownLatch(1); - } - - @Before - public void setUp() { - latch = new CountDownLatch(1); - } - - - @Test - public void test_00_fetchAllImageTransformation() { - - imageParams.put("auto", "webp"); - imageParams.put("quality", 200); - imageParams.put("width", 100); - imageParams.put("height", 50); - imageParams.put("format", "png"); - imageParams.put("crop", "3:5"); - imageParams.put("trim", "20,20,20,20"); - imageParams.put("disable", "upscale"); - imageParams.put("pad", "10,10,10,10"); - imageParams.put("bg-color", "#FFFFFF"); - imageParams.put("dpr", 20); - imageParams.put("canvas", "3:5"); - imageParams.put("orient", "l"); - - String image_url = stack.ImageTransform(IMAGE_URL, imageParams); - int counter = 0; - if (image_url.contains("?")) { - String[] imgKeys = image_url.split("\\?"); - String rightUrl = imgKeys[1]; - String[] getAllPairs = rightUrl.split("\\&"); - counter = 0; - if (imageParams.size() > 0) { - for (int i = 0; i < imageParams.size(); i++) { - String keyValueParis = getAllPairs[i]; - Log.i(TAG, "pairs:--> " + keyValueParis); - ++counter; - } - } - } else { - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - - if (counter == imageParams.size()) { - latch.countDown(); - Log.i(TAG, "Testcases Passed"); - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - } - - - @Test - public void test_01_fetchAllImageTransformation() { - - imageParams.put("auto", "webp"); - imageParams.put("quality", 200); - imageParams.put("width", 100); - imageParams.put("height", 50); - imageParams.put("format", "png"); - imageParams.put("crop", "3:5"); - - String image_url = stack.ImageTransform(IMAGE_URL, imageParams); - int counter = 0; - /* check url contains "?" */ - if (image_url.contains("?")) { - String[] imgKeys = image_url.split("\\?"); - String rightUrl = imgKeys[1]; - String[] getAllPairs = rightUrl.split("\\&"); - counter = 0; - if (imageParams.size() > 0) { - for (int i = 0; i < imageParams.size(); i++) { - String keyValueParis = getAllPairs[i]; - Log.i(TAG, "pairs:--> " + keyValueParis); - ++counter; - } - } - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - - if (counter == imageParams.size()) { - latch.countDown(); - Log.i(TAG, "Testcases Passed"); - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - } - - - @Test - public void test_02_fetchAllImageTransformation() { - imageParams.put("trim", "20,20,20,20"); - imageParams.put("disable", "upscale"); - imageParams.put("pad", "10,10,10,10"); - imageParams.put("bg-color", "#FFFFFF"); - imageParams.put("dpr", 20); - imageParams.put("canvas", "3:5"); - imageParams.put("orient", "l"); - String image_url = stack.ImageTransform(IMAGE_URL, imageParams); - int counter = 0; - /* check url contains "?" */ - if (!image_url.equalsIgnoreCase("") && image_url.contains("?")) { - String[] imgKeys = image_url.split("\\?"); - String rightUrl = imgKeys[1]; - String[] getAllPairs = rightUrl.split("\\&"); - counter = 0; - if (imageParams.size() > 0) { - for (int i = 0; i < imageParams.size(); i++) { - String keyValueParis = getAllPairs[i]; - Log.i(TAG, "pairs:--> " + keyValueParis); - ++counter; - } - } - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - - if (counter == imageParams.size()) { - latch.countDown(); - Log.i(TAG, "Testcases Passed"); - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - } - - - @Test - public void test_03_fetchAllImageTransformation() { - - - imageParams.put("trim", "20,20,20,20"); - imageParams.put("disable", "upscale"); - imageParams.put("canvas", "3:5"); - imageParams.put("orient", "l"); - - String image_url = stack.ImageTransform(IMAGE_URL, imageParams); - int counter = 0; - /* check url contains "?" */ - if (image_url.contains("?")) { - String[] imgKeys = image_url.split("\\?"); - String rightUrl = imgKeys[1]; - String[] getAllPairs = rightUrl.split("\\&"); - counter = 0; - if (imageParams.size() > 0) { - for (int i = 0; i < imageParams.size(); i++) { - String keyValueParis = getAllPairs[i]; - Log.i(TAG, "pairs:--> " + keyValueParis); - ++counter; - } - } - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - - if (counter == imageParams.size()) { - latch.countDown(); - Log.i(TAG, "Testcases Passed"); - } else { - Log.i(TAG, "Testcases Failed"); - try { - latch.await(); - } catch (Exception e) { - Log.i(TAG, "---------------||" + e.toString()); - } - } - } -} diff --git a/contentstack/src/azure-eu/java/AzureEUTest.java b/contentstack/src/azure-eu/java/AzureEUTest.java new file mode 100644 index 00000000..00821f86 --- /dev/null +++ b/contentstack/src/azure-eu/java/AzureEUTest.java @@ -0,0 +1,20 @@ +package com.contentstack.sdk; + +import static org.junit.Assert.assertEquals; + +import android.content.Context; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.shaileshmishra.myapplication", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/contentstack/src/azure-na/java/AzureNATest.java b/contentstack/src/azure-na/java/AzureNATest.java new file mode 100644 index 00000000..00821f86 --- /dev/null +++ b/contentstack/src/azure-na/java/AzureNATest.java @@ -0,0 +1,20 @@ +package com.contentstack.sdk; + +import static org.junit.Assert.assertEquals; + +import android.content.Context; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.shaileshmishra.myapplication", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/contentstack/src/eu/java/EUInstrumentedTest.java b/contentstack/src/eu/java/EUInstrumentedTest.java new file mode 100644 index 00000000..00821f86 --- /dev/null +++ b/contentstack/src/eu/java/EUInstrumentedTest.java @@ -0,0 +1,20 @@ +package com.contentstack.sdk; + +import static org.junit.Assert.assertEquals; + +import android.content.Context; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.shaileshmishra.myapplication", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/contentstack/src/main/java/com/contentstack/sdk/Asset.java b/contentstack/src/main/java/com/contentstack/sdk/Asset.java index 6e96bec4..828e609d 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Asset.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Asset.java @@ -78,7 +78,6 @@ protected void setStackInstance(Stack stack) { * @return {@link Asset} instance. */ public Asset configure(JSONObject jsonObject) { - AssetModel model = null; model = new AssetModel(jsonObject, true, false); this.contentType = model.contentType; @@ -108,7 +107,6 @@ public Asset configure(JSONObject jsonObject) { * */ public void setHeader(String key, String value) { - if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) { removeHeader(key); headerGroupLocal.put(key, value); @@ -465,9 +463,7 @@ private void fetchFromCache(File cacheFile, FetchResultCallback callback) { //Asset modeling from cache. private void setCacheModel(File cacheFile, FetchResultCallback callback) { - AssetModel model = new AssetModel(SDKUtil.getJsonFromCacheFile(cacheFile), false, true); - this.contentType = model.contentType; this.fileSize = model.fileSize; this.uploadUrl = model.uploadUrl; @@ -475,9 +471,7 @@ private void setCacheModel(File cacheFile, FetchResultCallback callback) { this.json = model.json; this.assetUid = model.uploadedUid; this.setTags(model.tags); - model = null; - if (callback != null) { callback.onRequestFinish(ResponseType.CACHE); } diff --git a/contentstack/src/main/java/com/contentstack/sdk/AssetModel.java b/contentstack/src/main/java/com/contentstack/sdk/AssetModel.java index bd069495..4e0d7105 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/AssetModel.java +++ b/contentstack/src/main/java/com/contentstack/sdk/AssetModel.java @@ -45,7 +45,6 @@ public AssetModel(JSONObject responseJSON, boolean isArray, boolean isFromCache) if (json.opt("tags") instanceof JSONArray) { if ((json.has("tags")) && (json.opt("tags") != null) && (!(json.opt("tags").equals("")))) { - JSONArray tagsArray = (JSONArray) json.opt("tags"); if (tagsArray.length() > 0) { int count = tagsArray.length(); @@ -59,6 +58,7 @@ public AssetModel(JSONObject responseJSON, boolean isArray, boolean isFromCache) if (json != null && json.has("_metadata")) { JSONObject _metadataJSON = json.optJSONObject("_metadata"); + assert _metadataJSON != null; Iterator iterator = _metadataJSON.keys(); _metadata = new WeakHashMap<>(); while (iterator.hasNext()) { diff --git a/contentstack/src/main/java/com/contentstack/sdk/AssetsModel.java b/contentstack/src/main/java/com/contentstack/sdk/AssetsModel.java index e96de11a..1ba82a22 100644 --- a/contentstack/src/main/java/com/contentstack/sdk/AssetsModel.java +++ b/contentstack/src/main/java/com/contentstack/sdk/AssetsModel.java @@ -11,18 +11,13 @@ */ class AssetsModel { - List objects = new ArrayList(); public AssetsModel(JSONObject jsonObject, boolean isFromCache) { - jsonObject = !isFromCache && jsonObject.opt("response") == null ? jsonObject : jsonObject.optJSONObject("response"); - JSONArray jsonArray = jsonObject != null && jsonObject.has("assets") ? jsonObject.optJSONArray("assets") : null; - if (jsonArray != null) { for (int i = 0; i < jsonArray.length(); i++) { - AssetModel model = new AssetModel(jsonArray.optJSONObject(i), true, false); objects.add(model); model = null; diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java b/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java index 8eafd183..5ba1f8b8 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java @@ -20,8 +20,7 @@ */ class CSConnectionRequest implements IRequestModelHTTP { - private static final String TAG = "CSConnectionRequest"; - + private static final String TAG = CSConnectionRequest.class.getSimpleName(); private String urlToCall; private SDKConstant.RequestMethod method; private String controller; @@ -138,11 +137,9 @@ public void onRequestFailed(JSONObject error, int statusCode, ResultCallBack cal if (errorJObject != null) { errorMessage = (errorJObject).isNull("error_message") ? "" : (errorJObject).optString("error_message"); - if ((!errorJObject.isNull("error_code")) && (!errorJObject.optString("error_code").contains(" "))) { errorCode = (Integer) errorJObject.opt("error_code"); } - if (!errorJObject.isNull("errors")) { resultHashMap = new HashMap(); if (errorJObject.opt("errors") instanceof JSONObject) { @@ -178,30 +175,24 @@ public void onRequestFailed(JSONObject error, int statusCode, ResultCallBack cal @Override public void onRequestFinished(CSHttpConnection request) { - responseJSON = request.getResponse(); - String controller = request.getController(); if (cacheFileName != null) { createFileIntoCacheDir(responseJSON); } - if (controller.equalsIgnoreCase(SDKController.GET_QUERY_ENTRIES)) { - EntriesModel model = new EntriesModel(responseJSON, null, false); notifyClass.getResult(model.formName, null); notifyClass.getResultObject(model.objectList, responseJSON, false); model = null; } else if (controller.equalsIgnoreCase(SDKController.SINGLE_QUERY_ENTRIES)) { - EntriesModel model = new EntriesModel(responseJSON, null, false); notifyClass.getResult(model.formName, null); notifyClass.getResultObject(model.objectList, responseJSON, true); model = null; } else if (controller.equalsIgnoreCase(SDKController.GET_ENTRY)) { - EntryModel model = new EntryModel(responseJSON, null, false, false, false); entryInstance.resultJson = model.jsonObject; entryInstance.ownerEmailId = model.ownerEmailId; @@ -227,12 +218,9 @@ public void onRequestFinished(CSHttpConnection request) { AssetsModel assetsModel = new AssetsModel(responseJSON, false); List objectList = assetsModel.objects; assetsModel = null; - assetLibrary.getResultObject(objectList, responseJSON, false); - } else if (controller.equalsIgnoreCase(SDKController.GET_ASSETS)) { AssetModel model = new AssetModel(responseJSON, false, false); - assetInstance.contentType = model.contentType; assetInstance.fileSize = model.fileSize; assetInstance.uploadUrl = model.uploadUrl; @@ -260,9 +248,7 @@ public void onRequestFinished(CSHttpConnection request) { if (request.getCallBackObject() != null) { ((ContentTypesCallback) request.getCallBackObject()).onRequestFinish(model); } - } - } protected void createFileIntoCacheDir(Object jsonObject) { @@ -270,10 +256,7 @@ protected void createFileIntoCacheDir(Object jsonObject) { JSONObject jsonObj = new JSONObject(); JSONObject mainJsonObj = new JSONObject(); JSONObject headerJson = new JSONObject(); - - jsonObj = paramsJSON; - Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("UTC")); cal.setTime(new Date()); @@ -292,9 +275,7 @@ protected void createFileIntoCacheDir(Object jsonObject) { headerJson.put(key, entry.getValue()); } mainJsonObj.put("header", headerJson); - File cacheFile = new File(cacheFileName); - if (cacheFile.exists()) { cacheFile.delete(); } diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java index 0f579ede..6f66bb07 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java @@ -222,11 +222,8 @@ private String getParams(HashMap params) { @Override public void send() { String url = null; - String protocol = SDKConstant.PROTOCOL; int requestId = getRequestId(requestMethod); final HashMap headers = new HashMap<>(); - int count = this.headers.size(); - if (requestMethod == SDKConstant.RequestMethod.GET) { String params = setFormParamsGET(formParams); if (params != null) { @@ -247,7 +244,6 @@ public void send() { headers.put("X-User-Agent", "contentstack-android/" + SDKConstant.SDK_VERSION); jsonObjectRequest = new JSONUTF8Request(requestId, url, requestJSON, response -> { responseJSON = response; - Log.i("response", response.toString()); if (responseJSON != null) { connectionRequest.onRequestFinished(CSHttpConnection.this); } @@ -259,23 +255,10 @@ public Map getHeaders() { }; jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(SDKConstant.TimeOutDuration, SDKConstant.NumRetry, SDKConstant.BackOFMultiplier)); jsonObjectRequest.setShouldCache(false); - Contentstack.addToRequestQueue(protocol, jsonObjectRequest, info); + Contentstack.addToRequestQueue(SDKConstant.PROTOCOL, jsonObjectRequest, info); } - private void httpRequest(String url) { - JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, requestJSON, response -> { - responseJSON = response; - if (responseJSON != null) { - connectionRequest.onRequestFinished(CSHttpConnection.this); - } - }, this::generateBuiltError); - - jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(SDKConstant.TimeOutDuration, SDKConstant.NumRetry, SDKConstant.BackOFMultiplier)); - jsonObjectRequest.setShouldCache(false); - Contentstack.addToRequestQueue("https://", jsonObjectRequest, info); - } - private String defaultUserAgent() { String agent = System.getProperty("http.agent"); return agent != null ? agent : ("Android" + System.getProperty("java.version")); diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSUtil.java b/contentstack/src/main/java/com/contentstack/sdk/CSUtil.java index 5ea25180..1e78754f 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSUtil.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSUtil.java @@ -1,6 +1,9 @@ package com.contentstack.sdk; import android.annotation.SuppressLint; +import android.content.Context; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -23,8 +26,8 @@ public class CSUtil { * @return {@link Calendar} object. * @throws ParseException

Example :
*
-     *                                                                       Util.parseDate(dateString, TimeZone.getDefault());
-     *                                                                       
+ * Util.parseDate(dateString, TimeZone.getDefault()); + * */ public static Calendar parseDate(String date, TimeZone timeZone) throws ParseException { ArrayList knownPatterns = new ArrayList(); @@ -59,8 +62,8 @@ public static Calendar parseDate(String date, TimeZone timeZone) throws ParseExc * @return {@link Calendar} object. * @throws ParseException

Example :
*
-     *                                                                                               Util.parseDate(dateString, "yyyy-MM-dd'T'HH:mm:ssZ", TimeZone.getTimeZone("GMT"));
-     *                                                                                             
+ * Util.parseDate(dateString, "yyyy-MM-dd'T'HH:mm:ssZ", TimeZone.getTimeZone("GMT")); + * */ @SuppressLint("SimpleDateFormat") public static Calendar parseDate(String date, String dateFormat, TimeZone timeZone) throws ParseException { @@ -108,4 +111,12 @@ public static Calendar parseDate(String date, String dateFormat, TimeZone timeZo } ; + + protected static void isNetworkAvailable(Context context) { + ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + if (connectivityManager.getNetworkInfo(0) != null || connectivityManager.getNetworkInfo(1).getState() != null) { + SDKConstant.IS_NETWORK_AVAILABLE = connectivityManager.getActiveNetworkInfo() != null; + } else + SDKConstant.IS_NETWORK_AVAILABLE = connectivityManager.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED || connectivityManager.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED; + } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/ClearCache.java b/contentstack/src/main/java/com/contentstack/sdk/ClearCache.java index 9d26fb30..f0a388b0 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/ClearCache.java +++ b/contentstack/src/main/java/com/contentstack/sdk/ClearCache.java @@ -29,17 +29,13 @@ public void onReceive(Context context, Intent intent) { if (cacheResponseFolder.isDirectory()) { File[] childFiles = cacheResponseFolder.listFiles(); - for (File child : childFiles) { File file = new File(cacheResponseFolder, child.getName()); - File sessionFile = new File(cacheResponseFolder.getPath() + File.separator + "Session"); File installationFile = new File(cacheResponseFolder.getPath() + File.separator + "Installation"); - if ((file.getName().equalsIgnoreCase(sessionFile.getName())) || (file.getName().equalsIgnoreCase(installationFile.getName()))) { } else { - if (file.exists()) { JSONObject jsonObj = SDKUtil.getJsonFromCacheFile(file); if (jsonObj != null) { diff --git a/contentstack/src/main/java/com/contentstack/sdk/Config.java b/contentstack/src/main/java/com/contentstack/sdk/Config.java index 262a6f23..4ca35af1 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Config.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Config.java @@ -8,7 +8,6 @@ * @author contentstack.com, Inc */ public class Config { - protected String PROTOCOL = "https://"; protected String URL = "cdn.contentstack.io"; protected String VERSION = "v3"; @@ -21,12 +20,14 @@ public class Config { * @param region

* Note: Default region sets to us * - *

Example :
+ *

Example For Different Regions:
*

-     *                                                                                                                               config.setRegion(ContentstackRegion.US);
-     *                                                                                                                               
+ * config.setRegion(ContentstackRegion.US); + * config.setRegion(ContentstackRegion.EU); + * config.setRegion(ContentstackRegion.AZURE_EU); + * config.setRegion(ContentstackRegion.AZURE_NA); + * */ - public ContentstackRegion setRegion(ContentstackRegion region) { this.region = region; return this.region; @@ -47,7 +48,6 @@ public enum ContentstackRegion {US, EU, AZURE_NA, AZURE_EU} * Config config = new Config(); * */ - public Config() { } @@ -55,7 +55,6 @@ public Config() { * Sets host name of the Contentstack server. * * @param hostName host name. - * *

* Note: Default hostname sets to cdn.contentstack.io * and default protocol is HTTPS. diff --git a/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java b/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java index 90e42531..6543dd64 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java +++ b/contentstack/src/main/java/com/contentstack/sdk/ConnectionStatus.java @@ -30,7 +30,7 @@ public ConnectionStatus() { @Override public void onReceive(Context context, Intent intent) { - Contentstack.isNetworkAvailable(context); + CSUtil.isNetworkAvailable(context); if (!IS_NETWORK_AVAILABLE) { //no net connection diff --git a/contentstack/src/main/java/com/contentstack/sdk/ContentType.java b/contentstack/src/main/java/com/contentstack/sdk/ContentType.java index f6e2dca6..3b631e9f 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/ContentType.java +++ b/contentstack/src/main/java/com/contentstack/sdk/ContentType.java @@ -101,7 +101,6 @@ public Entry entry(String entryUid) { entry.formHeader = getHeader(localHeader); entry.setContentTypeInstance(this); entry.setUid(entryUid); - return entry; } diff --git a/contentstack/src/main/java/com/contentstack/sdk/ContentTypesModel.java b/contentstack/src/main/java/com/contentstack/sdk/ContentTypesModel.java index dceed4af..5e363b92 100644 --- a/contentstack/src/main/java/com/contentstack/sdk/ContentTypesModel.java +++ b/contentstack/src/main/java/com/contentstack/sdk/ContentTypesModel.java @@ -6,6 +6,8 @@ import org.json.JSONException; import org.json.JSONObject; +import java.util.Objects; + public class ContentTypesModel { private JSONObject responseJSON = new JSONObject(); @@ -20,7 +22,7 @@ public void setJSON(JSONObject responseJSON) { try { this.responseJSON = responseJSON.getJSONObject("content_type"); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } } @@ -28,7 +30,7 @@ public void setJSON(JSONObject responseJSON) { try { this.responseJSONArray = responseJSON.getJSONArray("content_types"); } catch (JSONException e) { - Log.e(TAG, e.getLocalizedMessage()); + Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } } diff --git a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java index 51bdc69c..de72638b 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java @@ -4,8 +4,6 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; import android.os.SystemClock; import android.text.TextUtils; @@ -13,28 +11,30 @@ import com.android.volley.RequestQueue; import com.android.volley.toolbox.Volley; +import org.jetbrains.annotations.NotNull; + import java.io.File; /** - * Contains all Contentstack SDK classes and functions. + * Contains all Contentstack SDK Classes And Methods. * * @author ishaileshmishra */ public class Contentstack { private static final String TAG = Contentstack.class.getSimpleName(); + /** + * The constant requestQueue. + */ protected static RequestQueue requestQueue; + + private static Context ctx; private static Contentstack instance; - protected static Context context = null; - private Contentstack() { + private Contentstack(Context context) { throw new IllegalStateException("Private constructor not allowed"); } - public Contentstack(Context applicationContext) { - context = applicationContext; - } - /** * Authenticates the stack api key of your stack. * This must be called before your stack uses Contentstack sdk. @@ -45,32 +45,16 @@ public Contentstack(Context applicationContext) { * @param apiKey The api Key of your stack on Contentstack. * @param deliveryToken The Delivery Token for the stack * @param environment environment name - * @return {@link Stack} instance. - * - *

Example :
- *

-     * Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "stag");
-     * 
+ * @return {@link Stack} instance.

Example :
 Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "stag"); 
+ * @throws Exception the exception */ - public static Stack stack(Context context, String apiKey, String deliveryToken, String environment) throws Exception { - if (context != null) { - if (!TextUtils.isEmpty(apiKey)) { - if (!TextUtils.isEmpty(deliveryToken)) { - if (!TextUtils.isEmpty(environment)) { - Config config = new Config(); - config.setEnvironment(environment); - return initializeStack(context, apiKey, deliveryToken, config); - } else { - throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_ENVIRONMENT_IS_NULL); - } - } else { - throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_ACCESS_TOKEN_IS_NULL); - } - } else { - throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_API_KEY_IS_NULL); - } + public static Stack stack(@NotNull Context context, @NotNull String apiKey, @NotNull String deliveryToken, @NotNull String environment) throws Exception { + if (TextUtils.isEmpty(apiKey) || TextUtils.isEmpty(deliveryToken) || TextUtils.isEmpty(environment)) { + Config config = new Config(); + config.setEnvironment(environment); + return initializeStack(context, apiKey, deliveryToken, config); } else { - throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_CONTEXT_IS_NULL); + throw new Exception(SDKConstant.EMPTY_CREDENTIALS_NOT_ALLOWED); } } @@ -83,39 +67,18 @@ public static Stack stack(Context context, String apiKey, String deliveryToken, * @param context application context. * @param apiKey The api Key of your stack on Contentstack. * @param deliveryToken The delivery token for the stack on Contentstack + * @param environment the environment * @param config {@link Config} instance to set environment and other configuration details. - * @return {@link Stack} instance. - * - *

Example :
- *
-     * Config config = new Config();
-     * config.setEnvironment("stag");
-     * Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", config);
+     * @return {@link Stack} instance. 

Example :
 Config config = new Config(); config.setEnvironment("stag"); Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", config);
+     * @throws Exception the exception
      */
-    public static Stack stack(Context context, String apiKey, String deliveryToken, String environment, Config config) throws Exception {
-        if (context != null) {
-            if (!TextUtils.isEmpty(apiKey)) {
-                if (!TextUtils.isEmpty(deliveryToken)) {
-                    if (!TextUtils.isEmpty(environment)) {
-
-                        if (config != null) {
-                            config.setEnvironment(environment);
-                        } else {
-                            config = new Config();
-                            config.setEnvironment(environment);
-                        }
-                        return initializeStack(context, apiKey, deliveryToken, config);
-                    } else {
-                        throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_ENVIRONMENT_IS_NULL);
-                    }
-                } else {
-                    throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_ACCESS_TOKEN_IS_NULL);
-                }
-            } else {
-                throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_API_KEY_IS_NULL);
-            }
+    public static Stack stack(@NotNull Context context, @NotNull String apiKey, @NotNull String deliveryToken, @NotNull String environment, @NotNull Config config) throws Exception {
+        if (TextUtils.isEmpty(apiKey) || TextUtils.isEmpty(deliveryToken) || TextUtils.isEmpty(environment)) {
+            config = new Config();
+            config.setEnvironment(environment);
+            return initializeStack(context, apiKey, deliveryToken, config);
         } else {
-            throw new Exception(SDKConstant.ERROR_MESSAGE_STACK_CONTEXT_IS_NULL);
+            throw new Exception(SDKConstant.EMPTY_CREDENTIALS_NOT_ALLOWED);
         }
     }
 
@@ -124,82 +87,78 @@ private static Stack initializeStack(Context appContext, String apiKey, String d
         Stack stack = new Stack(apiKey.trim());
         stack.setHeader("api_key", apiKey);
         stack.setHeader("access_token", deliveryToken);
-        context = appContext;
         stack.setConfig(config);
-        if (context != null) {
-            try {
-                File queryCacheFile = context.getDir("ContentstackCache", 0);
-                SDKConstant.cacheFolderName = queryCacheFile.getPath();
-                clearCache(context);
-            } catch (Exception e) {
-                SDKUtil.showLog(TAG, "Contentstack-" + e.getLocalizedMessage());
-            }
+        try {
+            ctx = appContext;
+            File queryCacheFile = appContext.getDir(SDKConstant.CACHE, 0);
+            SDKConstant.cacheFolderName = queryCacheFile.getPath();
+            SDKUtil.clearCache(appContext);
+        } catch (Exception e) {
+            SDKUtil.showLog(TAG, SDKConstant.CACHE + e.getLocalizedMessage());
         }
         return stack;
     }
 
-
-    /********************************************************************************************************
-     *
-     * // Private Functionality
+    /**
+     * Gets instance.
      *
-     ********************************************************************************************************/
-
-
-    public static synchronized Contentstack getInstance(Context context) {
+     * @param context the context
+     * @return the instance
+     */
+    protected static synchronized Contentstack getInstance(Context context) {
         if (instance == null) {
             instance = new Contentstack(context);
         }
         return instance;
     }
 
-    public RequestQueue getRequestQueue() {
+    /**
+     * Gets request queue.
+     *
+     * @return the request queue
+     */
+    protected RequestQueue getRequestQueue() {
         if (requestQueue == null) {
-            requestQueue = Volley.newRequestQueue(context);
+            requestQueue = Volley.newRequestQueue(ctx);
         }
         return requestQueue;
     }
 
-    public  void addToRequestQueue(Request req) {
+    /**
+     * Add to request queue.
+     *
+     * @param  the type parameter
+     * @param req the req
+     */
+    protected  void addToRequestQueue(Request req) {
         getRequestQueue().add(req);
     }
 
+    /**
+     * Gets request queue.
+     *
+     * @param protocol the protocol
+     * @return the request queue
+     */
     protected static RequestQueue getRequestQueue(String protocol) {
         if (requestQueue == null) {
-            requestQueue = Volley.newRequestQueue(context);
+            requestQueue = Volley.newRequestQueue(ctx);
         }
         return requestQueue;
     }
 
+    /**
+     * Add to request queue.
+     *
+     * @param       the type parameter
+     * @param protocol the protocol
+     * @param req      the req
+     * @param tag      the tag
+     */
     protected static  void addToRequestQueue(String protocol, Request req, String tag) {
         req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
         getRequestQueue(protocol).add(req);
     }
 
-    /**
-     * To start schedule for clearing cache.
-     *
-     * @param context application context.
-     */
-
-    private static void clearCache(Context context) {
-        Intent alarmIntent = new Intent("StartContentStackClearingCache");
-        alarmIntent.setPackage(context.getPackageName());
-        int flag = PendingIntent.FLAG_UPDATE_CURRENT;
-        if (android.os.Build.VERSION.SDK_INT >= 23) flag = PendingIntent.FLAG_IMMUTABLE | flag;
-        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, flag);
-        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
-        alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), AlarmManager.INTERVAL_DAY, pendingIntent);
-    }
 
-    /**
-     * To check network availability.
-     */
-    protected static void isNetworkAvailable(Context context) {
-        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
-        if (connectivityManager.getNetworkInfo(0) != null || connectivityManager.getNetworkInfo(1).getState() != null) {
-            SDKConstant.IS_NETWORK_AVAILABLE = connectivityManager.getActiveNetworkInfo() != null;
-        } else
-            SDKConstant.IS_NETWORK_AVAILABLE = connectivityManager.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED || connectivityManager.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED;
-    }
 }
diff --git a/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java b/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java
index c5c43186..5438415d 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java
@@ -2,183 +2,51 @@
 
 import java.util.ArrayList;
 
-/**
- * The Contentstack Sdk contain constants.
- *
- * @author contentstack.com, Inc
- */
 public class SDKConstant {
 
-    /**
-     * The constant debug.
-     */
+    protected static final String ENVIRONMENT = "environment";
+    protected static final String CACHE = "ContentstackCache";
     public static final boolean debug = false;
-    /**
-     * The constant IS_NETWORK_AVAILABLE.
-     */
     public static boolean IS_NETWORK_AVAILABLE = true;
-    /**
-     * The constant PROTOCOL.
-     */
     public static String PROTOCOL = "https://";
-    /**
-     * The constant SDK_VERSION.
-     */
     public static String SDK_VERSION = "3.12.0";
-    /**
-     * The constant NO_NETWORK_CONNECTION.
-     */
     public final static int NO_NETWORK_CONNECTION = 408;
-    /**
-     * The constant TimeOutDuration.
-     */
     public final static int TimeOutDuration = 30000; // timeout in millisecond
-    /**
-     * The constant NumRetry.
-     */
     public final static int NumRetry = 0;
-    /**
-     * The constant BackOFMultiplier.
-     */
     public final static int BackOFMultiplier = 0;
-
-    /**
-     * The constant cancelledCallController.
-     */
-//Implemented for single network call cancellation. for class-level network call cancellation.
     public static ArrayList cancelledCallController = new ArrayList();
-
-    /**
-     * Directory path to store offline data.
-     * used to saved cached network calls with response.
-     */
     public static String cacheFolderName;
 
-    /**
-     * The enum Request method.
-     */
     public static enum RequestMethod {
-
-        /**
-         * Get request method.
-         */
         GET,
-        /**
-         * Post request method.
-         */
         POST,
-        /**
-         * Put request method.
-         */
         PUT,
-        /**
-         * Delete request method.
-         */
         DELETE
     }
 
-    /**
-     * The enum Call controller.
-     */
     public static enum callController {
-        /**
-         * Query call controller.
-         */
         QUERY,
-        /**
-         * Entry call controller.
-         */
         ENTRY,
-        /**
-         * Stack call controller.
-         */
         STACK,
-        /**
-         * Asset call controller.
-         */
         ASSET,
-        /**
-         * Sync call controller.
-         */
         SYNC,
-        /**
-         * Content types call controller.
-         */
         CONTENT_TYPES,
-        /**
-         * Asset library call controller.
-         */
         ASSET_LIBRARY;
     }
 
 
-    /**
-     * The constant PLEASE_PROVIDE_VALID_JSON.
-     */
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public final static String PLEASE_PROVIDE_VALID_JSON = "Please provide valid JSON.";
-    /**
-     * The constant ERROR_MESSAGE_STACK_CONTEXT_IS_NULL.
-     */
-    public final static String ERROR_MESSAGE_STACK_CONTEXT_IS_NULL = "Context can not be null.";
-    /**
-     * The constant ERROR_MESSAGE_STACK_API_KEY_IS_NULL.
-     */
-    public final static String ERROR_MESSAGE_STACK_API_KEY_IS_NULL = "Stack api key can not be null.";
-    /**
-     * The constant PLEASE_SET_CONTENT_TYPE_NAME.
-     */
+    public final static String EMPTY_CREDENTIALS_NOT_ALLOWED = "Empty credentials are not allowed, Please provide a valid one";
     public final static String PLEASE_SET_CONTENT_TYPE_NAME = "Please set contentType name.";
-    /**
-     * The constant PLEASE_SET_ENTRY_UID.
-     */
     public final static String PLEASE_SET_ENTRY_UID = "Please set entry uid.";
-    /**
-     * The constant ERROR_MESSAGE_STACK_ACCESS_TOKEN_IS_NULL.
-     */
-    public final static String ERROR_MESSAGE_STACK_ACCESS_TOKEN_IS_NULL = "Access token can not be null.";
-    /**
-     * The constant ERROR_MESSAGE_STACK_ENVIRONMENT_IS_NULL.
-     */
-    public final static String ERROR_MESSAGE_STACK_ENVIRONMENT_IS_NULL = "Environment can not be null.";
-    /**
-     * The constant CONNECTION_ERROR.
-     */
     public final static String CONNECTION_ERROR = "Connection error";
-    /**
-     * The constant AUTHENTICATION_NOT_PRESENT.
-     */
     public final static String AUTHENTICATION_NOT_PRESENT = "Authentication Not present.";
-    /**
-     * The constant PARSING_ERROR.
-     */
     public final static String PARSING_ERROR = "Parsing Error.";
-    /**
-     * The constant TRY_AGAIN.
-     */
     public final static String TRY_AGAIN = "Server interaction went wrong, Please try again.";
-    /**
-     * The constant ERROR_MESSAGE_DEFAULT.
-     */
     public final static String ERROR_MESSAGE_DEFAULT = "Oops! Something went wrong. Please try again.";
-    /**
-     * The constant NOT_AVAILABLE.
-     */
     public final static String NOT_AVAILABLE = "Network not available.";
-    /**
-     * The constant STACK_FIRST.
-     */
     public final static String STACK_FIRST = "You must called Contentstack.stack() first";
-    /**
-     * The constant PROVIDE_VALID_PARAMS.
-     */
     public final static String PROVIDE_VALID_PARAMS = "Please provide valid params.";
-    /**
-     * The constant ENTRY_IS_NOT_PRESENT_IN_CACHE.
-     */
     public final static String ENTRY_IS_NOT_PRESENT_IN_CACHE = "ENTRY is not present in cache";
-    /**
-     * The constant NETWORK_CALL_RESPONSE.
-     */
     public final static String NETWORK_CALL_RESPONSE = "Error while saving network call response.";
 }
diff --git a/contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java b/contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java
index 01bc3fe7..460b41a8 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/SDKUtil.java
@@ -1,6 +1,11 @@
 package com.contentstack.sdk;
 
 import android.annotation.SuppressLint;
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.os.SystemClock;
 import android.util.Log;
 
 import org.json.JSONObject;
@@ -23,6 +28,8 @@
  */
 public class SDKUtil {
 
+    private static final String CLEAR_CACHE = "StartContentStackClearingCache";
+
     public SDKUtil() {
     }
 
@@ -32,6 +39,15 @@ public static void showLog(String tag, String message) {
         }
     }
 
+    protected static void clearCache(Context context) {
+        Intent alarmIntent = new Intent(CLEAR_CACHE);
+        alarmIntent.setPackage(context.getPackageName());
+        int flag = PendingIntent.FLAG_UPDATE_CURRENT;
+        if (android.os.Build.VERSION.SDK_INT >= 23) flag = PendingIntent.FLAG_IMMUTABLE | flag;
+        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, flag);
+        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+        alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), AlarmManager.INTERVAL_DAY, pendingIntent);
+    }
 
     /**
      * To check if required response within given time window available in cache
@@ -152,8 +168,8 @@ public String getMD5FromString(String value) {
      * @return {@link Calendar} object.
      * @throws ParseException 

Example :
*
-     *                                                                        Util.parseDate(dateString, TimeZone.getDefault());
-     *                                                                      
+ * Util.parseDate(dateString, TimeZone.getDefault()); + *
*/ public static Calendar parseDate(String date, TimeZone timeZone) { ArrayList knownPatterns = new ArrayList<>(); @@ -187,8 +203,8 @@ public static Calendar parseDate(String date, TimeZone timeZone) { * @return {@link Calendar} object. * @throws ParseException

Example :
*
-     *                                                                        BuiltUtil.parseDate(dateString, "yyyy-MM-dd'T'HH:mm:ssZ", TimeZone.getTimeZone("GMT"));
-     *                                                                      
+ * BuiltUtil.parseDate(dateString, "yyyy-MM-dd'T'HH:mm:ssZ", TimeZone.getTimeZone("GMT")); + *
*/ @SuppressLint("SimpleDateFormat") public static Calendar parseDate(String date, String dateFormat, TimeZone timeZone) throws ParseException { diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index 412538f9..54df759f 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -1,5 +1,6 @@ package com.contentstack.sdk; +import android.os.Build; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; @@ -38,9 +39,8 @@ public class Stack implements INotifyClass { protected String PROTOCOL = "https://"; protected String URL = "cdn.contentstack.io"; protected String VERSION = "v3"; - protected String SYNC_KEY = "sync"; protected Config config; - protected ArrayMap headerGroup_app; + protected ArrayMap headerGroupApp; private JSONObject syncParams = null; protected String skip = null; protected String limit = null; @@ -48,13 +48,15 @@ public class Stack implements INotifyClass { private SyncResultCallBack syncCallBack; - private Stack() throws IllegalAccessException { - throw new IllegalAccessException("Can not initialise using constructor"); + protected Stack() { } - protected Stack(String stackApiKey) { - this.stackApiKey = stackApiKey; - this.localHeader = new ArrayMap<>(); + protected Stack(@NotNull String apiKey) { + this.stackApiKey = apiKey; + if (this.localHeader == null) { + this.localHeader = new ArrayMap<>(); + } + this.localHeader.put("api_key", this.stackApiKey); } protected void setConfig(Config config) { @@ -95,7 +97,6 @@ protected void setConfig(Config config) { *

Example :
*
      * Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "stag");
-     *
      * ContentType contentType = stack.contentType("blog");
      * 
*/ @@ -183,7 +184,7 @@ public String getApplicationKey() { *

*/ public String getAccessToken() { - return localHeader != null ? (String) localHeader.get("access_token") : null; + return this.localHeader != null ? (String) this.localHeader.get("access_token") : null; } /** @@ -199,7 +200,7 @@ public String getAccessToken() { */ public void removeHeader(String key) { if (!TextUtils.isEmpty(key)) { - localHeader.remove(key); + this.localHeader.remove(key); } } @@ -219,7 +220,16 @@ public void removeHeader(String key) { */ public void setHeader(String key, String value) { if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) { - localHeader.put(key, value); + this.localHeader.put(key, value); + } + } + + public void setHeaders(@NotNull ArrayMap headers) { + if (this.localHeader == null) { + this.localHeader = new ArrayMap<>(); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + headers.forEach((key, value) -> this.localHeader.put(key, value)); } } @@ -277,25 +287,24 @@ private String getImageUrl() { * @param params query parameters * @param callback ContentTypesCallback * 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.
+     *                                                                                                                                                                                                 }
+     *                                                                                                                                                                                                 }
+     *                                                                                                                                                                                                 });
+     *                                                                                                                                                                                                 
*/ public void getContentTypes(JSONObject params, final ContentTypesCallback callback) { try { String URL = "/" + this.VERSION + "/content_types"; - ArrayMap headers = getHeader(localHeader); + ArrayMap headers = getHeader(this.localHeader); if (params == null) { params = new JSONObject(); } @@ -338,10 +347,12 @@ 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. * - * - * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); - * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} - * + *

Example :
+ *
+     *
+     *                                                                                                                                                                                                                             Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
+     *                                                                                                                                                                                                                             stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {}
+     *                                                                                                                                                                                                                             
*/ public void sync(SyncResultCallBack syncCallBack) { @@ -391,7 +402,7 @@ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncC * and the details of the content that was deleted or updated. *

Example :
*
-     *                                                                                                                                            
+ *
*/ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { try { @@ -412,8 +423,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); @@ -553,10 +564,10 @@ public void sync(String contentType, Date fromDate, Language language, PublishTy try { syncParams = new JSONObject(); syncParams.put("init", true); - syncParams.put("start_from", startFromDate); - syncParams.put("content_type_uid", contentType); - syncParams.put("type", type.toString().toLowerCase()); - syncParams.put("locale", this.localeCode); + syncParams = (startFromDate == null || startFromDate.isEmpty()) ? null : syncParams.put("start_from", startFromDate); + syncParams = (contentType == null || contentType.isEmpty()) ? null : syncParams.put("content_type_uid", contentType); + syncParams = type == null ? null : syncParams.put("type", type.toString().toLowerCase()); + syncParams = (this.localeCode == null || this.localeCode.isEmpty()) ? null : syncParams.put("locale", this.localeCode); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -568,10 +579,10 @@ public void sync(String contentType, Date fromDate, String locale, PublishType t try { syncParams = new JSONObject(); syncParams.put("init", true); - syncParams.put("start_from", startFromDate); - syncParams.put("content_type_uid", contentType); - syncParams.put("type", type.toString().toLowerCase()); - syncParams.put("locale", locale); + syncParams = (contentType == null || contentType.isEmpty()) ? null : syncParams.put("content_type_uid", contentType); + syncParams = (startFromDate == null || startFromDate.isEmpty()) ? null : syncParams.put("start_from", startFromDate); + syncParams = (locale == null || locale.isEmpty()) ? null : syncParams.put("locale", locale); + syncParams = type == null ? null : syncParams.put("type", type.toString().toLowerCase()); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -583,26 +594,18 @@ public void sync(String contentType, Date fromDate, String locale, PublishType t * The enum Publish type. */ public enum PublishType { - ENTRY_PUBLISHED, - ENTRY_UNPUBLISHED, - ENTRY_DELETED, - ASSET_PUBLISHED, - ASSET_UNPUBLISHED, - ASSET_DELETED, - CONTENT_TYPE_DELETED + ENTRY_PUBLISHED, ENTRY_UNPUBLISHED, ENTRY_DELETED, ASSET_PUBLISHED, ASSET_UNPUBLISHED, ASSET_DELETED, CONTENT_TYPE_DELETED } private void requestSync(final SyncResultCallBack callback) { try { - String URL = "/" + this.VERSION + "/stacks/" + SYNC_KEY; - ArrayMap headers = getHeader(localHeader); - JSONObject urlQueries = new JSONObject(); - if (headers.containsKey("environment")) { - syncParams.put("environment", headers.get("environment")); + String URL = "/" + this.VERSION + "/stacks/sync"; + ArrayMap headers = getHeader(this.localHeader); + if (headers.containsKey(SDKConstant.ENVIRONMENT)) { + syncParams.put(SDKConstant.ENVIRONMENT, headers.get(SDKConstant.ENVIRONMENT)); } - urlQueries = syncParams; - fetchFromNetwork(URL, urlQueries, headers, null, new SyncResultCallBack() { + fetchFromNetwork(URL, syncParams, headers, null, new SyncResultCallBack() { @Override public void onCompletion(SyncStack syncStack, Error error) { if (error == null) { @@ -650,7 +653,7 @@ private HashMap getUrlParams(JSONObject urlQueriesJSON) { private ArrayMap getHeader(ArrayMap localHeader) { - ArrayMap mainHeader = headerGroup_app; + ArrayMap mainHeader = headerGroupApp; ArrayMap classHeaders = new ArrayMap<>(); if (localHeader != null && localHeader.size() > 0) { if (mainHeader != null && mainHeader.size() > 0) { @@ -669,7 +672,7 @@ private ArrayMap getHeader(ArrayMap localHeader) return localHeader; } } else { - return headerGroup_app; + return headerGroupApp; } } diff --git a/contentstack/src/test/java/com/contentstack/sdk/AssetTest.java b/contentstack/src/test/java/com/contentstack/sdk/AssetTest.java deleted file mode 100644 index 9c679d1f..00000000 --- a/contentstack/src/test/java/com/contentstack/sdk/AssetTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.contentstack.sdk; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -class AssetTest { - - @Test - void setTags() { - } - - @Test - void addParam() { - } - - @Test - void includeDimension() { - } - - @Test - void includeFallback() { - } -} \ No newline at end of file diff --git a/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java b/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java new file mode 100644 index 00000000..7c805ba1 --- /dev/null +++ b/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java @@ -0,0 +1,30 @@ +package com.contentstack.sdk; + +import org.junit.Test; + +import static org.junit.Assert.*; + +import android.util.ArrayMap; +import android.util.Log; + +public class ExampleUnitTest { + @Test + public void defaultTest() { + assertEquals(4, 2 + 2); + } + + @Test + public void stack() { + Stack stack = new Stack("blte00eab6e0747e802"); + ArrayMap headers = new ArrayMap<>(); + stack.setHeaders(headers); + stack.sync(new SyncResultCallBack() { + @Override + public void onCompletion(SyncStack syncStack, Error error) { + Log.d("TAG", syncStack.getItems().get(0).toString()); + } + }); + assertEquals(4, 2 + 2); + } + +} \ No newline at end of file diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index 5e16304c..b111c8c6 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -1,35 +1,46 @@ apply plugin: 'maven-publish' apply plugin: 'signing' +ext { + PUBLISH_GROUP_ID = 'com.contentstack.sdk' + PUBLISH_ARTIFACT_ID = 'android' + PUBLISH_VERSION = '3.12.0-SNAPSHOT' + POM_NAME = 'contentstack-android' + WEBSITE = 'http://www.contentstack.com' + PUBLISH_DESCRIPTION = 'The Content Delivery SDK is used to retrieve content from your Contentstack account and deliver it to your web or mobile properties.' + PUBLISH_URL = 'https://github.com/contentstack/contentstack-android' + PUBLISH_LICENSE_NAME = 'MIT License' + PUBLISH_LICENSE_URL = 'https://github.com/contentstack/contentstack-android/blob/master/LICENSE' + PUBLISH_DEVELOPER_ID = 'ishaileshmishra' + PUBLISH_DEVELOPER_NAME = 'Shailesh Mishra' + PUBLISH_DEVELOPER_EMAIL = 'mobile@contentstack.com' + PUBLISH_SCM_CONNECTION = 'scm:git@github.com:contentstack/contentstack-android' + SCM_DEVELOPER_CONNECTION = 'scm:git@github.com:contentstack/contentstack-android.git' + PUBLISH_SCM_URL = 'https://github.com/contentstack/contentstack-android/tree/master' +} tasks.register('androidSourcesJar', Jar) { archiveClassifier.set('sources') if (project.plugins.findPlugin("com.android.library")) { - // For Android libraries from android.sourceSets.main.java.srcDirs from android.sourceSets.main.kotlin.srcDirs } else { - // For pure Kotlin libraries, in case you have them from sourceSets.main.java.srcDirs from sourceSets.main.kotlin.srcDirs } } - artifacts { archives androidSourcesJar } -group = "com.contentstack.sdk" -version = "3.11.0-SNAPSHOT" - afterEvaluate { publishing { publications { release(MavenPublication) { - groupId = 'com.contentstack.sdk' - artifactId = 'android' - version = '3.11.0-SNAPSHOT' + groupId = PUBLISH_GROUP_ID + artifactId = PUBLISH_ARTIFACT_ID + version = PUBLISH_VERSION if (project.plugins.findPlugin("com.android.library")) { from components.release } else { @@ -37,29 +48,28 @@ afterEvaluate { } artifact androidSourcesJar pom { - name = 'contentstack-android' - description = 'Android SDK for Contentstack Content Delivery API, Contentstack is a headless CMS with an API-first approach' - url = 'http://www.contentstack.com' + name = POM_NAME + description = PUBLISH_DESCRIPTION + url = WEBSITE licenses { license { - name = 'The MIT License' - url = 'http://www.opensource.org/licenses/mit-license.php' + name = PUBLISH_LICENSE_NAME + url = PUBLISH_LICENSE_URL } } developers { developer { - id = 'ishaileshmishra' - name = 'Shailesh Mishra' - email = 'mobile@contentstack.com' + id = PUBLISH_DEVELOPER_ID + name = PUBLISH_DEVELOPER_NAME + email = PUBLISH_DEVELOPER_EMAIL } } scm { - connection = 'scm:git@github.com:contentstack/contentstack-android' - developerConnection = 'scm:git@github.com:contentstack/contentstack-android.git' - url = 'https://github.com/contentstack/contentstack-android' + connection = PUBLISH_SCM_CONNECTION + developerConnection = SCM_DEVELOPER_CONNECTION + url = PUBLISH_SCM_URL } - } } } diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle index a04452f5..00b0eb66 100644 --- a/scripts/publish-root.gradle +++ b/scripts/publish-root.gradle @@ -12,13 +12,15 @@ if (secretPropsFile.exists()) { new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } p.each { name, value -> ext[name] = value } } else { - // Use system environment variables - ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') - ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') - ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') - ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') - ext["signing.password"] = System.getenv('SIGNING_PASSWORD') - ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE') + def localProperties = new Properties() + localProperties.load(new FileInputStream(rootProject.file("local.properties"))) + + ext["ossrhUsername"] = localProperties['mavenCentralUsername'] + ext["ossrhPassword"] = localProperties['mavenCentralPassword'] + ext["sonatypeStagingProfileId"] = localProperties['sonatypeStagingProfileId'] + ext["signing.keyId"] = localProperties['signing.keyId'] + ext["signing.password"] = localProperties['signing.password'] + ext["signing.secretKeyRingFile"] = localProperties['signing.secretKeyRingFile'] } nexusPublishing { @@ -27,11 +29,15 @@ nexusPublishing { stagingProfileId = sonatypeStagingProfileId username = ossrhUsername password = ossrhPassword - if (project.version.endsWith('-SNAPSHOT')) { - snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots")) - } else { - nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) - } + nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/")) + + +// if (project.version.endsWith('-SNAPSHOT')) { +// snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots")) +// } else { +// nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) +// } } } } From 854df8d1c9ff383f492e4f4f070a2ebc361842e7 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 3 May 2023 11:36:40 +0530 Subject: [PATCH 08/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- contentstack/build.gradle | 2 + .../sdk/ExampleInstrumentedTest.java | 54 ++++++++++++--- contentstack/src/main/AndroidManifest.xml | 36 ++++++---- .../java/com/contentstack/sdk/CSUtil.java | 16 ++--- .../com/contentstack/sdk/Contentstack.java | 8 +-- .../main/java/com/contentstack/sdk/Query.java | 1 - .../main/java/com/contentstack/sdk/Stack.java | 68 +++++++++---------- .../com/contentstack/sdk/TestActivity.java | 11 +-- .../com/contentstack/sdk/ExampleUnitTest.java | 11 +-- 9 files changed, 123 insertions(+), 84 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 6dedc205..2ba5fd96 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -15,6 +15,8 @@ android { multiDexEnabled true vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "android.test.InstrumentationTestRunner" + testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner" testHandleProfiling true testFunctionalTest true } diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java index 3d3ac705..091ac2f0 100644 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java @@ -1,34 +1,66 @@ package com.contentstack.sdk; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import android.content.Context; import androidx.test.core.app.ApplicationProvider; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -@RunWith(AndroidJUnit4.class) +import java.util.Date; + + +@RunWith(AndroidJUnit4ClassRunner.class) public class ExampleInstrumentedTest { + + static final String apiKey = BuildConfig.APIKey; + static final String deliveryToken = BuildConfig.deliveryToken; + static final String environment = BuildConfig.environment; + static Stack stack = null; + + @Test + @BeforeClass + public static void useAppContext() throws Exception { + Context ctx = ApplicationProvider.getApplicationContext(); + stack = Contentstack.stack(ctx, apiKey, deliveryToken, environment); + assertEquals("com.contentstack.sdk.test", ctx.getPackageName().toLowerCase()); + } + @Test - public void useAppContext() { - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("contentstack.sdk.test", appContext.getPackageName()); + public void testAPINotNull() { + assertNotNull(apiKey); } @Test - public void initSDK() throws Exception { - Context ctx = ApplicationProvider.getApplicationContext(); - Stack stack = Contentstack.stack(ctx, "", "", ""); - stack.sync(new SyncResultCallBack() { + public void testDeliveryTokenNotNull() { + assertNotNull(deliveryToken); + } + + @Test + public void testEnvironmentNotNull() { + assertNotNull(environment); + } + + @Test + public void initSDK() { + stack.sync(null); + assertNotNull(stack.syncParams); + } + + + @Test + public void syncSDKWIthAllParams() { + stack.sync("abcd", new Date(), "en-us", Stack.PublishType.ENTRY_PUBLISHED, new SyncResultCallBack() { @Override public void onCompletion(SyncStack syncStack, Error error) { } }); - assertEquals(4, 2 + 2); + assertNotNull(stack.syncParams); } } \ No newline at end of file diff --git a/contentstack/src/main/AndroidManifest.xml b/contentstack/src/main/AndroidManifest.xml index dd44442a..cdc1ae97 100755 --- a/contentstack/src/main/AndroidManifest.xml +++ b/contentstack/src/main/AndroidManifest.xml @@ -7,19 +7,29 @@ - - - - - - - + + + + + + + + + + + diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSUtil.java b/contentstack/src/main/java/com/contentstack/sdk/CSUtil.java index 1e78754f..cef8f146 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSUtil.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSUtil.java @@ -4,6 +4,7 @@ import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.util.Log; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -24,13 +25,9 @@ public class CSUtil { * * @param date date in ISO format. * @return {@link Calendar} object. - * @throws ParseException

Example :
- *
-     *                                                                                              Util.parseDate(dateString, TimeZone.getDefault());
-     *                                                                                              
*/ - public static Calendar parseDate(String date, TimeZone timeZone) throws ParseException { - ArrayList knownPatterns = new ArrayList(); + public static Calendar parseDate(String date, TimeZone timeZone) { + ArrayList knownPatterns = new ArrayList<>(); knownPatterns.add("yyyy-MM-dd'T'HH:mm:ssZ"); knownPatterns.add("yyyy-MM-dd'T'HH:mm:ss'Z'"); knownPatterns.add("yyyy-MM-dd'T'HH:mm.ss'Z'"); @@ -47,7 +44,7 @@ public static Calendar parseDate(String date, TimeZone timeZone) throws ParseExc try { return parseDate(date, formatString, timeZone); } catch (ParseException e) { - System.out.println(e.getLocalizedMessage()); + Log.e("CSUtils", e.getLocalizedMessage()); } } @@ -62,8 +59,8 @@ public static Calendar parseDate(String date, TimeZone timeZone) throws ParseExc * @return {@link Calendar} object. * @throws ParseException

Example :
*
-     *                                               Util.parseDate(dateString, "yyyy-MM-dd'T'HH:mm:ssZ", TimeZone.getTimeZone("GMT"));
-     *                                             
+ * Util.parseDate(dateString, "yyyy-MM-dd'T'HH:mm:ssZ", TimeZone.getTimeZone("GMT")); + * */ @SuppressLint("SimpleDateFormat") public static Calendar parseDate(String date, String dateFormat, TimeZone timeZone) throws ParseException { @@ -110,7 +107,6 @@ public static Calendar parseDate(String date, String dateFormat, TimeZone timeZo return cal; } - ; protected static void isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); diff --git a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java index de72638b..8191646d 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java @@ -1,10 +1,6 @@ package com.contentstack.sdk; -import android.app.AlarmManager; -import android.app.PendingIntent; import android.content.Context; -import android.content.Intent; -import android.os.SystemClock; import android.text.TextUtils; import com.android.volley.Request; @@ -49,7 +45,7 @@ private Contentstack(Context context) { * @throws Exception the exception */ public static Stack stack(@NotNull Context context, @NotNull String apiKey, @NotNull String deliveryToken, @NotNull String environment) throws Exception { - if (TextUtils.isEmpty(apiKey) || TextUtils.isEmpty(deliveryToken) || TextUtils.isEmpty(environment)) { + if (!TextUtils.isEmpty(apiKey) || !TextUtils.isEmpty(deliveryToken) || !TextUtils.isEmpty(environment)) { Config config = new Config(); config.setEnvironment(environment); return initializeStack(context, apiKey, deliveryToken, config); @@ -73,7 +69,7 @@ public static Stack stack(@NotNull Context context, @NotNull String apiKey, @Not * @throws Exception the exception */ public static Stack stack(@NotNull Context context, @NotNull String apiKey, @NotNull String deliveryToken, @NotNull String environment, @NotNull Config config) throws Exception { - if (TextUtils.isEmpty(apiKey) || TextUtils.isEmpty(deliveryToken) || TextUtils.isEmpty(environment)) { + if (!TextUtils.isEmpty(apiKey) || !TextUtils.isEmpty(deliveryToken) || !TextUtils.isEmpty(environment)) { config = new Config(); config.setEnvironment(environment); return initializeStack(context, apiKey, deliveryToken, config); diff --git a/contentstack/src/main/java/com/contentstack/sdk/Query.java b/contentstack/src/main/java/com/contentstack/sdk/Query.java index 08d87f7d..7c540415 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Query.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Query.java @@ -154,7 +154,6 @@ public Query where(String key, Object value) { public Query addQuery(String key, String value) { try { if (key != null && value != null) { - urlQueries.put(key, value); } else { throwException("and", SDKConstant.PROVIDE_VALID_PARAMS, null); diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index 54df759f..338012d5 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -41,7 +41,7 @@ public class Stack implements INotifyClass { protected String VERSION = "v3"; protected Config config; protected ArrayMap headerGroupApp; - private JSONObject syncParams = null; + protected JSONObject syncParams = null; protected String skip = null; protected String limit = null; protected String localeCode; @@ -289,17 +289,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 { @@ -350,9 +350,9 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap *

Example :
*
      *
-     *                                                                                                                                                                                                                             Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
-     *                                                                                                                                                                                                                             stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {}
-     *                                                                                                                                                                                                                             
+ * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); + * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} + * */ public void sync(SyncResultCallBack syncCallBack) { @@ -402,7 +402,7 @@ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncC * and the details of the content that was deleted or updated. *

Example :
*
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
+ * */ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { try { @@ -423,8 +423,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); @@ -559,19 +559,8 @@ private String getLanguageCode(Language language) { */ public void sync(String contentType, Date fromDate, Language language, PublishType type, SyncResultCallBack syncCallBack) { - String startFromDate = convertUTCToISO(fromDate); - this.localeCode = getLanguageCode(language); - try { - syncParams = new JSONObject(); - syncParams.put("init", true); - syncParams = (startFromDate == null || startFromDate.isEmpty()) ? null : syncParams.put("start_from", startFromDate); - syncParams = (contentType == null || contentType.isEmpty()) ? null : syncParams.put("content_type_uid", contentType); - syncParams = type == null ? null : syncParams.put("type", type.toString().toLowerCase()); - syncParams = (this.localeCode == null || this.localeCode.isEmpty()) ? null : syncParams.put("locale", this.localeCode); - } catch (JSONException e) { - Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); - } - this.requestSync(syncCallBack); + String locale = getLanguageCode(language); + sync(contentType, fromDate, locale, type, syncCallBack); } public void sync(String contentType, Date fromDate, String locale, PublishType type, SyncResultCallBack syncCallBack) { @@ -579,10 +568,19 @@ public void sync(String contentType, Date fromDate, String locale, PublishType t try { syncParams = new JSONObject(); syncParams.put("init", true); - syncParams = (contentType == null || contentType.isEmpty()) ? null : syncParams.put("content_type_uid", contentType); - syncParams = (startFromDate == null || startFromDate.isEmpty()) ? null : syncParams.put("start_from", startFromDate); - syncParams = (locale == null || locale.isEmpty()) ? null : syncParams.put("locale", locale); - syncParams = type == null ? null : syncParams.put("type", type.toString().toLowerCase()); + if (contentType != null && !contentType.isEmpty()) { + syncParams.put("content_type_uid", contentType); + } + if (!startFromDate.isEmpty()) { + syncParams.put("start_from", startFromDate); + } + if (locale != null && locale.isEmpty()) { + syncParams.put("locale", locale); + } + if (type != null && !type.toString().isEmpty()) { + syncParams.put("type", type.toString().toLowerCase()); + } + Log.e(TAG, syncParams.toString()); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } diff --git a/contentstack/src/main/java/com/contentstack/sdk/TestActivity.java b/contentstack/src/main/java/com/contentstack/sdk/TestActivity.java index 7225266d..93f38c2a 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/TestActivity.java +++ b/contentstack/src/main/java/com/contentstack/sdk/TestActivity.java @@ -1,15 +1,18 @@ package com.contentstack.sdk; -import android.app.Application; +import android.os.Bundle; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; /** * @author Contentstack.com, Inc */ -public class TestActivity extends Application { +public class TestActivity extends AppCompatActivity { @Override - public void onCreate() { - super.onCreate(); + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); } } diff --git a/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java b/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java index 7c805ba1..3db5bdfa 100644 --- a/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java +++ b/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java @@ -1,12 +1,12 @@ package com.contentstack.sdk; -import org.junit.Test; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import android.util.ArrayMap; import android.util.Log; +import org.junit.Test; + public class ExampleUnitTest { @Test public void defaultTest() { @@ -15,8 +15,11 @@ public void defaultTest() { @Test public void stack() { - Stack stack = new Stack("blte00eab6e0747e802"); + Stack stack = new Stack(""); ArrayMap headers = new ArrayMap<>(); + headers.put("api_key", ""); + headers.put("access_token", ""); + headers.put("environment", ""); stack.setHeaders(headers); stack.sync(new SyncResultCallBack() { @Override From 1db19f32e9b6689dfa3a97a3fa6c85346341a81b Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 3 May 2023 18:55:05 +0530 Subject: [PATCH 09/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- build.gradle | 7 +-- contentstack/build.gradle | 18 ++++-- .../sdk/ExampleInstrumentedTest.java | 19 ++++-- contentstack/src/main/AndroidManifest.xml | 24 ++++---- .../contentstack/sdk/CSHttpConnection.java | 4 +- .../main/java/com/contentstack/sdk/Stack.java | 60 +++++++++---------- .../com/contentstack/sdk/ExampleUnitTest.java | 20 ------- gradle/wrapper/gradle-wrapper.properties | 3 +- scripts/publish-module.gradle | 5 +- 9 files changed, 79 insertions(+), 81 deletions(-) diff --git a/build.gradle b/build.gradle index 389b0532..4fffe10f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,5 @@ buildscript { - ext.jacocoVersion = '0.8.8' - + ext.jacoco_version = '0.8.8' repositories { maven { url "https://plugins.gradle.org/m2/" } google() @@ -8,9 +7,9 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' //4.1.3 + classpath "com.android.tools.build:gradle:7.2.2" //7.0.4 classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' - classpath "org.jacoco:org.jacoco.core:$jacocoVersion" + classpath "org.jacoco:org.jacoco.core:$jacoco_version" } } diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 2ba5fd96..2d86b3b3 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -1,10 +1,11 @@ apply plugin: 'com.android.library' apply plugin: 'jacoco' + apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" android { - namespace 'com.contentstack.sdk' + //namespace 'com.contentstack.sdk' compileSdk 33 defaultConfig { @@ -15,10 +16,6 @@ android { multiDexEnabled true vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - testInstrumentationRunner "android.test.InstrumentationTestRunner" - testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner" - testHandleProfiling true - testFunctionalTest true } buildTypes { def localProperties = new Properties() @@ -70,4 +67,15 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' +// testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3' +// implementation 'androidx.appcompat:appcompat:1.6.1' +// implementation 'com.android.volley:volley:1.2.1' +// androidTestImplementation 'androidx.test:core:1.5.0' +// androidTestImplementation "androidx.test:runner:1.5.2" +// androidTestImplementation "androidx.test:rules:1.5.0" + +} +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } \ No newline at end of file diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java index 091ac2f0..b6c7c4e9 100644 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java @@ -7,8 +7,6 @@ import androidx.test.core.app.ApplicationProvider; import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; - -import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -23,9 +21,9 @@ public class ExampleInstrumentedTest { static final String environment = BuildConfig.environment; static Stack stack = null; + @Test - @BeforeClass - public static void useAppContext() throws Exception { + public void useAppContext() throws Exception { Context ctx = ApplicationProvider.getApplicationContext(); stack = Contentstack.stack(ctx, apiKey, deliveryToken, environment); assertEquals("com.contentstack.sdk.test", ctx.getPackageName().toLowerCase()); @@ -52,10 +50,21 @@ public void initSDK() { assertNotNull(stack.syncParams); } + @Test + public void syncLocale() { + stack.syncLocale("ar-eu", new SyncResultCallBack() { + @Override + public void onCompletion(SyncStack syncStack, Error error) { + + } + }); + assertNotNull(stack.syncParams); + } + @Test public void syncSDKWIthAllParams() { - stack.sync("abcd", new Date(), "en-us", Stack.PublishType.ENTRY_PUBLISHED, new SyncResultCallBack() { + stack.sync("content_type", new Date(), "en-us", Stack.PublishType.ENTRY_PUBLISHED, new SyncResultCallBack() { @Override public void onCompletion(SyncStack syncStack, Error error) { diff --git a/contentstack/src/main/AndroidManifest.xml b/contentstack/src/main/AndroidManifest.xml index cdc1ae97..d94c12f5 100755 --- a/contentstack/src/main/AndroidManifest.xml +++ b/contentstack/src/main/AndroidManifest.xml @@ -10,7 +10,11 @@ + android:exported="true"> + + + + - - - - + + - + \ No newline at end of file diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java index 6f66bb07..3decf64e 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java @@ -5,9 +5,7 @@ import android.util.Log; import com.android.volley.DefaultRetryPolicy; -import com.android.volley.Request; import com.android.volley.VolleyError; -import com.android.volley.toolbox.JsonObjectRequest; import org.json.JSONArray; import org.json.JSONObject; @@ -242,6 +240,8 @@ public void send() { headers.put("Content-Type", "application/json"); headers.put("User-Agent", defaultUserAgent()); headers.put("X-User-Agent", "contentstack-android/" + SDKConstant.SDK_VERSION); + + Log.d("url requested", url); jsonObjectRequest = new JSONUTF8Request(requestId, url, requestJSON, response -> { responseJSON = response; if (responseJSON != null) { diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index 338012d5..d4b4ee6a 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -357,8 +357,8 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap public void sync(SyncResultCallBack syncCallBack) { try { - syncParams = new JSONObject(); - syncParams.put("init", true); + this.syncParams = new JSONObject(); + this.syncParams.put("init", true); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -385,8 +385,8 @@ public void sync(SyncResultCallBack syncCallBack) { */ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncCallBack) { try { - syncParams = new JSONObject(); - syncParams.put("pagination_token", paginationToken); + this.syncParams = new JSONObject(); + this.syncParams.put("pagination_token", paginationToken); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -406,8 +406,8 @@ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncC */ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { try { - syncParams = new JSONObject(); - syncParams.put("sync_token", syncToken); + this.syncParams = new JSONObject(); + this.syncParams.put("sync_token", syncToken); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -429,9 +429,9 @@ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { String startFromDate = convertUTCToISO(fromDate); try { - syncParams = new JSONObject(); - syncParams.put("init", true); - syncParams.put("start_from", startFromDate); + this.syncParams = new JSONObject(); + this.syncParams.put("init", true); + this.syncParams.put("start_from", startFromDate); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -449,9 +449,9 @@ public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { */ public void syncContentType(String contentType, SyncResultCallBack syncCallBack) { try { - syncParams = new JSONObject(); - syncParams.put("init", true); - syncParams.put("content_type_uid", contentType); + this.syncParams = new JSONObject(); + this.syncParams.put("init", true); + this.syncParams.put("content_type_uid", contentType); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -477,9 +477,9 @@ private String convertUTCToISO(Date date) { public void syncLocale(Language language, SyncResultCallBack syncCallBack) { String localeCode = getLanguageCode(language); try { - syncParams = new JSONObject(); - syncParams.put("init", true); - syncParams.put("locale", localeCode); + this.syncParams = new JSONObject(); + this.syncParams.put("init", true); + this.syncParams.put("locale", localeCode); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -496,9 +496,9 @@ public void syncLocale(Language language, SyncResultCallBack syncCallBack) { */ public void syncLocale(@NotNull String localeCode, SyncResultCallBack syncCallBack) { try { - syncParams = new JSONObject(); - syncParams.put("init", true); - syncParams.put("locale", localeCode); + this.syncParams = new JSONObject(); + this.syncParams.put("init", true); + this.syncParams.put("locale", localeCode); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -524,9 +524,9 @@ public void syncLocale(@NotNull String localeCode, SyncResultCallBack syncCallBa public void syncPublishType(PublishType type, SyncResultCallBack syncCallBack) { try { - syncParams = new JSONObject(); - syncParams.put("init", true); - syncParams.put("type", type.toString().toLowerCase()); + this.syncParams = new JSONObject(); + this.syncParams.put("init", true); + this.syncParams.put("type", type.toString().toLowerCase()); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -566,21 +566,20 @@ public void sync(String contentType, Date fromDate, Language language, PublishTy public void sync(String contentType, Date fromDate, String locale, PublishType type, SyncResultCallBack syncCallBack) { String startFromDate = convertUTCToISO(fromDate); try { - syncParams = new JSONObject(); - syncParams.put("init", true); + this.syncParams = new JSONObject(); + this.syncParams.put("init", true); if (contentType != null && !contentType.isEmpty()) { - syncParams.put("content_type_uid", contentType); + this.syncParams.put("content_type_uid", contentType); } if (!startFromDate.isEmpty()) { - syncParams.put("start_from", startFromDate); + this.syncParams.put("start_from", startFromDate); } if (locale != null && locale.isEmpty()) { - syncParams.put("locale", locale); + this.syncParams.put("locale", locale); } if (type != null && !type.toString().isEmpty()) { - syncParams.put("type", type.toString().toLowerCase()); + this.syncParams.put("type", type.toString().toLowerCase()); } - Log.e(TAG, syncParams.toString()); } catch (JSONException e) { Log.e(TAG, Objects.requireNonNull(e.getLocalizedMessage())); } @@ -601,9 +600,10 @@ private void requestSync(final SyncResultCallBack callback) { String URL = "/" + this.VERSION + "/stacks/sync"; ArrayMap headers = getHeader(this.localHeader); if (headers.containsKey(SDKConstant.ENVIRONMENT)) { - syncParams.put(SDKConstant.ENVIRONMENT, headers.get(SDKConstant.ENVIRONMENT)); + this.syncParams.put(SDKConstant.ENVIRONMENT, headers.get(SDKConstant.ENVIRONMENT)); } - fetchFromNetwork(URL, syncParams, headers, null, new SyncResultCallBack() { + + fetchFromNetwork(URL, this.syncParams, headers, null, new SyncResultCallBack() { @Override public void onCompletion(SyncStack syncStack, Error error) { if (error == null) { diff --git a/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java b/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java index 3db5bdfa..e7748124 100644 --- a/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java +++ b/contentstack/src/test/java/com/contentstack/sdk/ExampleUnitTest.java @@ -2,9 +2,6 @@ import static org.junit.Assert.assertEquals; -import android.util.ArrayMap; -import android.util.Log; - import org.junit.Test; public class ExampleUnitTest { @@ -13,21 +10,4 @@ public void defaultTest() { assertEquals(4, 2 + 2); } - @Test - public void stack() { - Stack stack = new Stack(""); - ArrayMap headers = new ArrayMap<>(); - headers.put("api_key", ""); - headers.put("access_token", ""); - headers.put("environment", ""); - stack.setHeaders(headers); - stack.sync(new SyncResultCallBack() { - @Override - public void onCompletion(SyncStack syncStack, Error error) { - Log.d("TAG", syncStack.getItems().get(0).toString()); - } - }); - assertEquals(4, 2 + 2); - } - } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index baff06ff..e5bcd27d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ #Tue Dec 13 11:19:51 IST 2022 +#gradle-7.6-bin.zip distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index b111c8c6..8fc281e3 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -1,6 +1,7 @@ apply plugin: 'maven-publish' apply plugin: 'signing' + ext { PUBLISH_GROUP_ID = 'com.contentstack.sdk' PUBLISH_ARTIFACT_ID = 'android' @@ -23,10 +24,8 @@ tasks.register('androidSourcesJar', Jar) { archiveClassifier.set('sources') if (project.plugins.findPlugin("com.android.library")) { from android.sourceSets.main.java.srcDirs - from android.sourceSets.main.kotlin.srcDirs } else { from sourceSets.main.java.srcDirs - from sourceSets.main.kotlin.srcDirs } } @@ -34,6 +33,7 @@ artifacts { archives androidSourcesJar } + afterEvaluate { publishing { publications { @@ -76,6 +76,7 @@ afterEvaluate { } } + ext["signing.keyId"] = rootProject.ext["signing.keyId"] ext["signing.password"] = rootProject.ext["signing.password"] ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"] From 9b17c38707becafb6cddb765702aed697a94dc71 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 3 May 2023 19:06:47 +0530 Subject: [PATCH 10/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- scripts/publish-root.gradle | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle index 00b0eb66..919b787e 100644 --- a/scripts/publish-root.gradle +++ b/scripts/publish-root.gradle @@ -7,20 +7,10 @@ ext["ossrhPassword"] = '' ext["sonatypeStagingProfileId"] = '' File secretPropsFile = project.rootProject.file('local.properties') -if (secretPropsFile.exists()) { +if (!secretPropsFile.exists()) { Properties p = new Properties() new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } p.each { name, value -> ext[name] = value } -} else { - def localProperties = new Properties() - localProperties.load(new FileInputStream(rootProject.file("local.properties"))) - - ext["ossrhUsername"] = localProperties['mavenCentralUsername'] - ext["ossrhPassword"] = localProperties['mavenCentralPassword'] - ext["sonatypeStagingProfileId"] = localProperties['sonatypeStagingProfileId'] - ext["signing.keyId"] = localProperties['signing.keyId'] - ext["signing.password"] = localProperties['signing.password'] - ext["signing.secretKeyRingFile"] = localProperties['signing.secretKeyRingFile'] } nexusPublishing { From 4da4bcc59cc1489966e5ff4e6e99bcce4efe5183 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 3 May 2023 19:07:01 +0530 Subject: [PATCH 11/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- scripts/publish-root.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle index 919b787e..e0c8c7e5 100644 --- a/scripts/publish-root.gradle +++ b/scripts/publish-root.gradle @@ -7,7 +7,7 @@ ext["ossrhPassword"] = '' ext["sonatypeStagingProfileId"] = '' File secretPropsFile = project.rootProject.file('local.properties') -if (!secretPropsFile.exists()) { +if (secretPropsFile.exists()) { Properties p = new Properties() new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } p.each { name, value -> ext[name] = value } From a72a6cea7918de083e7a646ce11fc336e7da5791 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 3 May 2023 19:10:51 +0530 Subject: [PATCH 12/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- scripts/publish-module.gradle | 2 +- scripts/publish-root.gradle | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index 8fc281e3..b407a099 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -42,7 +42,7 @@ afterEvaluate { artifactId = PUBLISH_ARTIFACT_ID version = PUBLISH_VERSION if (project.plugins.findPlugin("com.android.library")) { - from components.release + //from components.release } else { artifact("$buildDir/libs/${project.getName()}-${version}.jar") } diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle index e0c8c7e5..39f328a6 100644 --- a/scripts/publish-root.gradle +++ b/scripts/publish-root.gradle @@ -21,8 +21,6 @@ nexusPublishing { password = ossrhPassword nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/")) - - // if (project.version.endsWith('-SNAPSHOT')) { // snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots")) // } else { From 5b718284cff248e0a441c87d6445631c9a81770c Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 3 May 2023 19:13:37 +0530 Subject: [PATCH 13/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- contentstack/build.gradle | 27 --------------------------- scripts/publish-module.gradle | 2 +- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 2d86b3b3..f055e95b 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -17,33 +17,6 @@ android { vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - buildTypes { - def localProperties = new Properties() - localProperties.load(new FileInputStream(rootProject.file("local.properties"))) - debug { - debuggable false - testCoverageEnabled true - buildConfigField "String", "host", localProperties['host'] - buildConfigField "String", "APIKey", localProperties['APIKey'] - buildConfigField "String", "deliveryToken", localProperties['deliveryToken'] - buildConfigField "String", "environment", localProperties['env'] - buildConfigField "String", "contentTypeUID", localProperties['contentType'] - buildConfigField "String", "assetUID", localProperties['assetUid'] - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - release { - debuggable false - minifyEnabled false - 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['env'] - buildConfigField "String", "contentTypeUID", localProperties['contentType'] - buildConfigField "String", "assetUID", localProperties['assetUid'] - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index b407a099..8fc281e3 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -42,7 +42,7 @@ afterEvaluate { artifactId = PUBLISH_ARTIFACT_ID version = PUBLISH_VERSION if (project.plugins.findPlugin("com.android.library")) { - //from components.release + from components.release } else { artifact("$buildDir/libs/${project.getName()}-${version}.jar") } From 72a4c2a39a290261dd74002cf98df4d85c35529d Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 3 May 2023 19:14:15 +0530 Subject: [PATCH 14/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- contentstack/build.gradle | 1 + scripts/publish-module.gradle | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index f055e95b..e40a3dd3 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -17,6 +17,7 @@ android { vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index 8fc281e3..b407a099 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -42,7 +42,7 @@ afterEvaluate { artifactId = PUBLISH_ARTIFACT_ID version = PUBLISH_VERSION if (project.plugins.findPlugin("com.android.library")) { - from components.release + //from components.release } else { artifact("$buildDir/libs/${project.getName()}-${version}.jar") } From a3502ca5d36a6c72ad17d4a00ac6d0b7d267a099 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Sat, 6 May 2023 15:04:23 +0530 Subject: [PATCH 15/17] CODEOWNERS update --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index d81d2232..07739234 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @contentstack/security-admin @contentstack/sdk-admin +* @contentstack/security-admin \ No newline at end of file From 45fff7eea802dfea7d64e485854f20abee3ce3ad Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Mon, 8 May 2023 15:39:55 +0530 Subject: [PATCH 16/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- contentstack/build.gradle | 38 ++++++++++++++++++++++++++----------- scripts/publish-root.gradle | 10 +++++----- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index e40a3dd3..6ade9825 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -1,13 +1,10 @@ apply plugin: 'com.android.library' apply plugin: 'jacoco' - apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" android { - //namespace 'com.contentstack.sdk' compileSdk 33 - defaultConfig { minSdk 19 targetSdk 33 @@ -17,7 +14,33 @@ android { vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - + buildTypes { + def localProperties = new Properties() + localProperties.load(new FileInputStream(rootProject.file("local.properties"))) + debug { + debuggable true + testCoverageEnabled true + buildConfigField "String", "host", localProperties['host'] + buildConfigField "String", "APIKey", localProperties['APIKey'] + buildConfigField "String", "deliveryToken", localProperties['deliveryToken'] + buildConfigField "String", "environment", localProperties['env'] + buildConfigField "String", "contentTypeUID", localProperties['contentType'] + buildConfigField "String", "assetUID", localProperties['assetUid'] + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + release { + debuggable false + minifyEnabled false + 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['env'] + buildConfigField "String", "contentTypeUID", localProperties['contentType'] + buildConfigField "String", "assetUID", localProperties['assetUid'] + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -41,13 +64,6 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' -// testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3' -// implementation 'androidx.appcompat:appcompat:1.6.1' -// implementation 'com.android.volley:volley:1.2.1' -// androidTestImplementation 'androidx.test:core:1.5.0' -// androidTestImplementation "androidx.test:runner:1.5.2" -// androidTestImplementation "androidx.test:rules:1.5.0" - } java { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle index 39f328a6..6ee1c85b 100644 --- a/scripts/publish-root.gradle +++ b/scripts/publish-root.gradle @@ -21,11 +21,11 @@ nexusPublishing { password = ossrhPassword nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/")) -// if (project.version.endsWith('-SNAPSHOT')) { -// snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots")) -// } else { -// nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) -// } + if (project.version.endsWith('-SNAPSHOT')) { + snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots")) + } else { + nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) + } } } } From 3dfbffd2c696c19b46f61c368c81467a44e870a4 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Mon, 8 May 2023 15:48:34 +0530 Subject: [PATCH 17/17] feat: [CS-37836] includeMetadata, Azure-EU and General Fixes --- contentstack/build.gradle | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/contentstack/build.gradle b/contentstack/build.gradle index 6ade9825..c91cacea 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -17,29 +17,6 @@ android { buildTypes { def localProperties = new Properties() localProperties.load(new FileInputStream(rootProject.file("local.properties"))) - debug { - debuggable true - testCoverageEnabled true - buildConfigField "String", "host", localProperties['host'] - buildConfigField "String", "APIKey", localProperties['APIKey'] - buildConfigField "String", "deliveryToken", localProperties['deliveryToken'] - buildConfigField "String", "environment", localProperties['env'] - buildConfigField "String", "contentTypeUID", localProperties['contentType'] - buildConfigField "String", "assetUID", localProperties['assetUid'] - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - release { - debuggable false - minifyEnabled false - 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['env'] - buildConfigField "String", "contentTypeUID", localProperties['contentType'] - buildConfigField "String", "assetUID", localProperties['assetUid'] - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8