Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taxonomy and Early Access Header #97

Merged
merged 181 commits into from
Dec 18, 2023
Merged
Changes from 1 commit
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
7145da1
Merge pull request #50 from contentstack/azure-na
ishaileshmishra Mar 16, 2022
50f38f5
Snyk integration
contentstack-admin May 30, 2022
ed7f57a
adding snyk secrets
contentstack-admin May 30, 2022
b8085e6
adding sca-monitor
contentstack-admin May 30, 2022
5c5082b
create sca-scan
contentstack-admin May 30, 2022
a31e6d4
create sast-scan
contentstack-admin May 30, 2022
16fe5c5
Merge pull request #54 from contentstack/dev
ishaileshmishra Jun 1, 2022
024daf0
Update codeql-analysis.yml
contentstack-admin Jun 14, 2022
b33a812
Merge pull request #59 from contentstack/compilejava
ishaileshmishra Jun 16, 2022
a277071
fix: pom.xml to reduce vulnerabilities
snyk-bot Jun 16, 2022
f45e7d7
Update codeql-analysis.yml
aravindbuilt Aug 1, 2022
2019d2f
Delete sca-monitor.yml
aravindbuilt Aug 1, 2022
f66ddd9
Update sast-scan.yml
aravindbuilt Aug 1, 2022
9c52cff
Update sca-scan.yml
aravindbuilt Aug 1, 2022
bbce574
Update secrets-scan.yml
aravindbuilt Aug 1, 2022
74f796c
codeql-analysis.yml
aravindbuilt Sep 15, 2022
f2c3368
sast-scan.yml
aravindbuilt Sep 15, 2022
abbf664
sca-scan.yml
aravindbuilt Sep 15, 2022
a407d91
secrets-scan.yml
aravindbuilt Sep 15, 2022
a8cb70f
codeql-analysis.yml
aravindbuilt Sep 21, 2022
76b30bb
sast-scan.yml
aravindbuilt Sep 21, 2022
bcec2c5
sca-scan.yml
aravindbuilt Sep 21, 2022
b9ac217
secrets-scan.yml
aravindbuilt Sep 21, 2022
84ee49d
jira.yml
aravindbuilt Oct 3, 2022
728247f
jira.yml
aravindbuilt Oct 4, 2022
b1ffeff
Merge branch 'master' into dev
ishaileshmishra Oct 10, 2022
1337f6d
Merge branch 'dev' of https://github.com/contentstack/contentstack-ja…
ishaileshmishra Oct 20, 2022
3087b34
Live Preview
ishaileshmishra Oct 31, 2022
7b35deb
Live Preview
ishaileshmishra Oct 31, 2022
8896b6c
Live Preview
ishaileshmishra Oct 31, 2022
eae094f
Live Preview
ishaileshmishra Oct 31, 2022
ac25c8e
Live Preview
ishaileshmishra Oct 31, 2022
4459dfe
jira.yml
aravindbuilt Nov 4, 2022
9766476
:potted_plant: plugins support
ishaileshmishra Dec 8, 2022
324ad8c
:potted_plant: plugins support
ishaileshmishra Dec 8, 2022
7c6fd6a
Plugins implemented
ishaileshmishra Dec 9, 2022
3ed997c
:potted_plant: plugins support
ishaileshmishra Dec 9, 2022
71cbcf5
:potted_plant: CI/CD Pipeline
ishaileshmishra Dec 21, 2022
da0011e
sca-scan.yml
aravindbuilt Jan 24, 2023
b4b6a64
jira.yml
aravindbuilt Jan 24, 2023
c15b29c
codeql-analysis.yml
aravindbuilt Jan 24, 2023
8c418fd
sast-scan.yml
aravindbuilt Jan 24, 2023
d2b1574
secrets-scan.yml
aravindbuilt Jan 24, 2023
c27211b
:potted_plant: #67 error handling infinite loop issue
ishaileshmishra Feb 6, 2023
0f3a6ee
:potted_plant: #67 error handling infinite loop issue
ishaileshmishra Feb 6, 2023
a9074c1
Merge branch 'master' into plugins
ishaileshmishra Feb 7, 2023
4be4741
Merge branch 'master' into plugins
uttamukkoji Feb 7, 2023
0bdb775
:potted_plant: #67 resolved
ishaileshmishra Feb 8, 2023
3087a07
:potted_plant: #67 resolved
ishaileshmishra Feb 8, 2023
a72347d
Merge remote-tracking branch 'origin/plugins' into plugins
ishaileshmishra Feb 8, 2023
589d6e1
:potted_plant: #67 resolved
ishaileshmishra Feb 8, 2023
72e487f
:potted_plant: #67 resolved
ishaileshmishra Feb 8, 2023
2e31abf
:potted_plant: #67 pom.xml and CHANGELOG.md updated
ishaileshmishra Feb 8, 2023
4a27817
:potted_plant: LICENSE file updated
ishaileshmishra Feb 9, 2023
3c1d456
:potted_plant: LICENSE file updated
ishaileshmishra Feb 9, 2023
d32b954
Merge pull request #68 from contentstack/plugins
ishaileshmishra Feb 10, 2023
7021f39
feat/CS-35325-include_ownership
ishaileshmishra Apr 10, 2023
85014f7
feat/CS-37219-azure-eu-and-include-metadata
ishaileshmishra Apr 10, 2023
0d477be
Merge branch 'master' into feat/CS-37219-azure-eu-and-include-metadata
ishaileshmishra Apr 10, 2023
6e8c041
feat/CS-37219-azure-eu-and-include-metadata
ishaileshmishra Apr 11, 2023
1782cdd
feat/CS-37219-azure-eu-and-include-metadata
ishaileshmishra Apr 11, 2023
1d785c7
feat/cs-37219 azure-eu and include_metadata
ishaileshmishra Apr 18, 2023
6f72739
Merge pull request #74 from contentstack/feat/CS-37219-azure-eu-and-i…
ishaileshmishra Apr 18, 2023
60e400e
Create check-branch.yml
aravindbuilt Apr 18, 2023
9d3070a
CODEOWNERS update
aravindbuilt May 6, 2023
06b1ccd
cs-39681-Utils and dependencies update
ishaileshmishra Jun 19, 2023
007719e
Merge pull request #82 from contentstack/fix/CS-39681/utils-enhancement
ishaileshmishra Jun 19, 2023
ad2f8f7
Merge pull request #83 from contentstack/next
ishaileshmishra Jun 28, 2023
a156aa6
Utils update
ishaileshmishra Aug 8, 2023
afb0efc
Utils update
ishaileshmishra Aug 8, 2023
8bfb574
Utils update
ishaileshmishra Aug 8, 2023
c3995ac
Utils update
ishaileshmishra Aug 8, 2023
280bc9a
Utils update
ishaileshmishra Aug 9, 2023
3afead4
Utils update
ishaileshmishra Aug 9, 2023
7b48985
Utils update
ishaileshmishra Aug 9, 2023
070a0f9
Utils update
ishaileshmishra Aug 9, 2023
730fcf9
run ci
ishaileshmishra Aug 9, 2023
1228a02
run ci
ishaileshmishra Aug 9, 2023
030dfe4
run ci
ishaileshmishra Aug 9, 2023
3154212
run ci
ishaileshmishra Aug 9, 2023
5cb11d6
run ci
ishaileshmishra Aug 10, 2023
1d381fa
run ci
ishaileshmishra Aug 10, 2023
b8d0a86
run ci
ishaileshmishra Aug 10, 2023
711e1b4
run ci
ishaileshmishra Aug 10, 2023
2f0f3c9
run ci
ishaileshmishra Aug 10, 2023
6fea00b
run ci
ishaileshmishra Aug 10, 2023
c257e97
run ci
ishaileshmishra Aug 10, 2023
6ad7d99
run ci
ishaileshmishra Aug 10, 2023
0082ce9
run ci
ishaileshmishra Aug 10, 2023
f45af75
run ci
ishaileshmishra Aug 10, 2023
5bfbabe
run ci
ishaileshmishra Aug 10, 2023
60bde0b
run ci
ishaileshmishra Aug 10, 2023
d4e611e
run ci
ishaileshmishra Aug 10, 2023
615d885
run ci
ishaileshmishra Aug 10, 2023
b046eca
run ci
ishaileshmishra Aug 10, 2023
529e659
run ci
ishaileshmishra Aug 10, 2023
69e1bf7
run ci
ishaileshmishra Aug 10, 2023
71272d4
run ci
ishaileshmishra Aug 10, 2023
ae97d85
run ci
ishaileshmishra Aug 10, 2023
ca73cd4
run ci
ishaileshmishra Aug 10, 2023
f3ad4a6
run ci
ishaileshmishra Aug 10, 2023
f58b346
run ci
ishaileshmishra Aug 10, 2023
02d6fa6
run ci
ishaileshmishra Aug 10, 2023
f174b5c
run ci
ishaileshmishra Aug 10, 2023
1d5e995
run ci
ishaileshmishra Aug 10, 2023
2b2cbba
run ci
ishaileshmishra Aug 10, 2023
a7eb3bb
run ci
ishaileshmishra Aug 10, 2023
9f7f5c4
run ci
ishaileshmishra Aug 10, 2023
0c0f129
run ci
ishaileshmishra Aug 10, 2023
7c10270
run ci
ishaileshmishra Aug 10, 2023
917854b
run ci
ishaileshmishra Aug 10, 2023
ed969d6
run ci
ishaileshmishra Aug 10, 2023
56ca186
GitHub Package Release
ishaileshmishra Aug 10, 2023
3ac4940
GitHub Package Release
ishaileshmishra Aug 10, 2023
801ac63
GitHub Package Release
ishaileshmishra Aug 10, 2023
62178c6
GitHub Package Release
ishaileshmishra Aug 10, 2023
32e3ea8
GitHub Package Release
ishaileshmishra Aug 10, 2023
b4030ab
GitHub Package Release
ishaileshmishra Aug 10, 2023
20b6651
GitHub Package Release
ishaileshmishra Aug 10, 2023
c8a603a
GitHub Package Release
ishaileshmishra Aug 10, 2023
369b2f1
GitHub Package Release
ishaileshmishra Aug 10, 2023
4d1214e
GitHub Package Release
ishaileshmishra Aug 10, 2023
87fa40c
GitHub Package Release
ishaileshmishra Aug 10, 2023
9c96d03
GitHub Package Release
ishaileshmishra Aug 10, 2023
fff95fe
Merge pull request #86 from contentstack/enh/CS-39681-utils-sdk-v1.2.3
ishaileshmishra Aug 10, 2023
d13d50c
Merge pull request #86 from contentstack/enh/CS-39681-utils-sdk-v1.2.3
ishaileshmishra Aug 10, 2023
ba5e302
Merge branch 'master' into next
ishaileshmishra Aug 17, 2023
fc95aa0
Merge branch 'master' into next
ishaileshmishra Aug 17, 2023
51c2765
tests fixed
ishaileshmishra Aug 17, 2023
eb25d57
tests fixed
ishaileshmishra Aug 17, 2023
5772e49
Merge pull request #87 from contentstack/next
ishaileshmishra Aug 18, 2023
b716d15
Merge pull request #87 from contentstack/next
ishaileshmishra Aug 18, 2023
7e04b9f
asset docs updated
ishaileshmishra Aug 18, 2023
ad9898e
asset docs updated
ishaileshmishra Aug 18, 2023
d5f9bd4
updated pom.xml
ishaileshmishra Aug 18, 2023
2342ba9
updated pom.xml
ishaileshmishra Aug 18, 2023
5f38c5c
pom.xml updated
ishaileshmishra Aug 18, 2023
d2033a1
pom.xml updated
ishaileshmishra Aug 18, 2023
06235df
pom.xml updated to latest
ishaileshmishra Sep 18, 2023
8f95a4b
pom.xml updated to latest
ishaileshmishra Sep 18, 2023
a0b15dc
Utils SDK Updated to latest version
ishaileshmishra Sep 27, 2023
8e941b7
Utils SDK Updated to latest version
ishaileshmishra Sep 27, 2023
cd56c03
Merge branch 'master' into next
ishaileshmishra Sep 27, 2023
c535ed2
Merge branch 'master' into next
ishaileshmishra Sep 27, 2023
3fed846
Utils SDK Updated to latest version
ishaileshmishra Oct 3, 2023
0fa2e93
Utils SDK Updated to latest version
ishaileshmishra Oct 3, 2023
f5046e0
Merge pull request #90 from contentstack/next
ishaileshmishra Oct 3, 2023
bb9085f
Merge pull request #90 from contentstack/next
ishaileshmishra Oct 3, 2023
8a14765
v1.12.3 Early Access Feature Support
ishaileshmishra Nov 16, 2023
06743ac
v1.12.3 Early Access Feature Support
ishaileshmishra Nov 16, 2023
ba7a011
v1.12.3 Early Access Feature Support
ishaileshmishra Nov 16, 2023
c82668e
v1.12.3 Early Access Feature Support
ishaileshmishra Nov 16, 2023
05fae73
Merge branch 'master' into next
ishaileshmishra Nov 16, 2023
31469d1
Merge branch 'master' into next
ishaileshmishra Nov 16, 2023
c02ae30
v1.12.3 Early Access Feature Support
ishaileshmishra Nov 16, 2023
b49cfc8
v1.12.3 Early Access Feature Support
ishaileshmishra Nov 16, 2023
5115af6
Merge remote-tracking branch 'origin/next' into next
ishaileshmishra Nov 16, 2023
884da74
Merge remote-tracking branch 'origin/next' into next
ishaileshmishra Nov 16, 2023
07bdf9d
v1.12.3 Early Access Feature Support
ishaileshmishra Nov 16, 2023
699265e
v1.12.3 Early Access Feature Support
ishaileshmishra Nov 16, 2023
0cbcb2f
v1.12.3
ishaileshmishra Dec 13, 2023
a046fa0
v1.12.3
ishaileshmishra Dec 13, 2023
fe28d6d
v1.12.3
ishaileshmishra Dec 13, 2023
f521de8
v1.12.3
ishaileshmishra Dec 14, 2023
2343fb9
v1.12.3
ishaileshmishra Dec 14, 2023
5539c4e
v1.12.3
ishaileshmishra Dec 14, 2023
5c0bf30
v1.12.3
ishaileshmishra Dec 15, 2023
5af4976
v1.12.3
ishaileshmishra Dec 15, 2023
74b6813
v1.12.3
ishaileshmishra Dec 15, 2023
4c25e36
v1.12.3
ishaileshmishra Dec 15, 2023
d0f2444
v1.12.3
ishaileshmishra Dec 15, 2023
bb32156
Merge branch 'next' into CS-42935/feat-taxonomy-and-eaf
ishaileshmishra Dec 15, 2023
77618f6
v1.12.3
ishaileshmishra Dec 15, 2023
a79b551
Merge remote-tracking branch 'origin/CS-42935/feat-taxonomy-and-eaf' …
ishaileshmishra Dec 15, 2023
86ab663
v1.12.3
ishaileshmishra Dec 15, 2023
71d0cbd
v1.12.3
ishaileshmishra Dec 15, 2023
5863a76
Merge pull request #96 from contentstack/CS-42935/feat-taxonomy-and-eaf
ishaileshmishra Dec 15, 2023
65f32c0
v1.12.3
ishaileshmishra Dec 15, 2023
9c725ac
v1.12.3
ishaileshmishra Dec 15, 2023
916bca1
Merge remote-tracking branch 'origin/next' into next
ishaileshmishra Dec 15, 2023
a5408fe
v1.12.3
ishaileshmishra Dec 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🪴 #67 error handling infinite loop issue
ishaileshmishra committed Feb 6, 2023
commit c27211b2a7c59aa62d31759f205bff6d6db5e468
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
<rxjava-source.version>3.1.5</rxjava-source.version>
<retrofit-source.version>2.9.0</retrofit-source.version>
<converter-gson-source.version>2.9.0</converter-gson-source.version>
<loggin.version>4.10.0</loggin.version>
<loggin.version>4.9.2</loggin.version>
<jococo-plugin.version>0.8.5</jococo-plugin.version>
<lombok-source.version>1.18.24</lombok-source.version>
<junit-jupiter.version>5.9.1</junit-jupiter.version>
@@ -197,7 +197,8 @@
</execution>
</executions>
</plugin>

<!--Generate overview.html file-->
<!-- -overview "/Users/shaileshmishra/Documents/workspace/contentstack/javaspace/contentstack-java/src/main/overview.html" -bottom "<b>Copyright © 2012-2022 Contentstack </b><sup>TM</sup>" -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
@@ -279,7 +280,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin-version}</version>
<version>${nexus-staging-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
1 change: 0 additions & 1 deletion src/main/java/com/contentstack/sdk/Asset.java
Original file line number Diff line number Diff line change
@@ -102,7 +102,6 @@ public void setHeader(@NotNull String headerKey, @NotNull String headerValue) {
* @param headerKey
* the header key
*
*
* <br>
* <br>
* <b>Example :</b><br>
35 changes: 21 additions & 14 deletions src/main/java/com/contentstack/sdk/AssetLibrary.java
Original file line number Diff line number Diff line change
@@ -10,7 +10,9 @@
import static com.contentstack.sdk.Constants.ENVIRONMENT;

/**
* The type Asset library.
* The Asset library is used to get list of assets available in the stack, We can apply filters on the assets also.
* The Get all assets request fetches the list of all the assets of a particular stack. It returns the content of each
* asset in JSON format.
*/
public class AssetLibrary implements INotifyClass {

@@ -34,8 +36,10 @@ protected void setStackInstance(@NotNull Stack stack) {
/**
* Sets header.
*
* @param headerKey the header key
* @param headerValue the header value
* @param headerKey
* the header key
* @param headerValue
* the header value
*/
public void setHeader(@NotNull String headerKey, @NotNull String headerValue) {
this.headers.put(headerKey, headerValue);
@@ -44,7 +48,8 @@ public void setHeader(@NotNull String headerKey, @NotNull String headerValue) {
/**
* Remove header.
*
* @param headerKey the header key
* @param headerKey
* the header key
*/
public void removeHeader(@NotNull String headerKey) {
if (!headerKey.isEmpty()) {
@@ -55,8 +60,10 @@ public void removeHeader(@NotNull String headerKey) {
/**
* Sort asset library.
*
* @param keyOrderBy the key order by
* @param orderby the orderby
* @param keyOrderBy
* the key order by
* @param orderby
* the orderby
* @return the asset library
*/
public AssetLibrary sort(String keyOrderBy, ORDERBY orderby) {
@@ -89,14 +96,13 @@ public AssetLibrary includeRelativeUrl() {
}

/**
* Retrieve the published content of the fallback locale if an entry is not
* localized in specified locale
* Retrieve the published content of the fallback locale if an entry is not localized in specified locale
*
* @return {@link AssetLibrary} object, so you can chain this call. <br>
* <br>
* <b>Example :</b><br>
*
* <pre class="prettyprint">
* <br>
* <b>Example :</b><br>
*
* <pre class="prettyprint">
* Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
* AssetLibrary assetLibObject = stack.assetLibrary();
* AssetLibrary.includeFallback();
@@ -119,7 +125,8 @@ public int getCount() {
/**
* Fetch all.
*
* @param callback the callback
* @param callback
* the callback
*/
public void fetchAll(FetchAssetsCallback callback) {
this.callback = callback;
@@ -128,7 +135,7 @@ public void fetchAll(FetchAssetsCallback callback) {
}

private void fetchFromNetwork(String url, JSONObject urlQueries, LinkedHashMap<String, Object> headers,
FetchAssetsCallback callback) {
FetchAssetsCallback callback) {
if (callback != null) {
HashMap<String, Object> urlParams = getUrlParams(urlQueries);
new CSBackgroundTask(this, stackInstance, Constants.FETCHALLASSETS, url, headers, urlParams,
12 changes: 6 additions & 6 deletions src/main/java/com/contentstack/sdk/Config.java
Original file line number Diff line number Diff line change
@@ -5,12 +5,13 @@
import org.json.JSONObject;

import java.net.Proxy;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;


/**
* The type Config. enables optional parameters while passing from stack
* The Config enables optional parameters while passing from stack. You can set different configs params to the stack
* like host, version, livePreview, endpoint, region, branch etc
*/
public class Config {

@@ -30,7 +31,7 @@ public class Config {
protected Proxy proxy = null;
protected ConnectionPool connectionPool = new ConnectionPool();

protected ArrayList<ContentstackPlugin> plugins = null;
protected List<ContentstackPlugin> plugins = null;

public String getBranch() {
return branch;
@@ -110,12 +111,11 @@ protected String getEndpoint() {
return endpoint + "/" + getVersion() + "/";
}

protected String setEndpoint(@NotNull String endpoint) {
protected void setEndpoint(@NotNull String endpoint) {
this.endpoint = endpoint;
return this.endpoint;
}

public void setPlugins(ArrayList<ContentstackPlugin> plugins) {
public void setPlugins(List<ContentstackPlugin> plugins) {
this.plugins = plugins;
}

101 changes: 44 additions & 57 deletions src/main/java/com/contentstack/sdk/Constants.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.contentstack.sdk;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.Level;
import org.jetbrains.annotations.NotNull;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.logging.Logger;

/**
@@ -16,7 +21,7 @@
public class Constants {

private static final Logger logger = Logger.getLogger(Constants.class.getSimpleName());
protected static final String SDK_VERSION = "1.10.1";
protected static final String SDK_VERSION = "1.10.2";
protected static final String ENVIRONMENT = "environment";
protected static final String CONTENT_TYPE_UID = "content_type_uid";
protected static final String ENTRY_UID = "entry_uid";
@@ -66,71 +71,53 @@ public enum REQUEST_CONTROLLER {
public static final String QUERY_EXCEPTION = "Please provide valid params.";



/**
* Parse date calendar.
*
* @param date
* the date
* @param timeZone
* the time zone
* @return the calendar
* @param dateString
* the date in string format
* @param zoneId
* the string zoneId
* @return Calendar
*/
public static Calendar parseDate(String date, TimeZone timeZone) {
ArrayList<String> 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'");
knownPatterns.add("yyyy-MM-dd'T'HH:mmZ");
knownPatterns.add("yyyy-MM-dd'T'HH:mm'Z'");
knownPatterns.add("yyyy-MM-dd'T'HH:mm'Z'");
knownPatterns.add("yyyy-MM-dd'T'HH:mm:ss");
knownPatterns.add("yyyy-MM-dd' 'HH:mm:ss");
knownPatterns.add("yyyy-MM-dd");
knownPatterns.add("HH:mm:ssZ");
knownPatterns.add("HH:mm:ss'Z'");

for (String formatString : knownPatterns) {
try {
return parseDate(date, formatString, timeZone);
} catch (ParseException e) {
logger.log(Level.WARNING, e.getLocalizedMessage(), e);
}
}
return null;
public static Calendar parseDateToTimeZone(@NotNull String dateString, @NotNull String zoneId) {
//String dateString = "2016-12-16T12:36:33.961Z";
Instant instant = Instant.parse(dateString);
// Define the target time zone
ZoneId targetTimeZone = ZoneId.of(zoneId);
// Convert the instant to the target time zone
ZonedDateTime dateTime = instant.atZone(targetTimeZone);
// Extract the year, month, day, hour, minute, and second
Calendar cal = Calendar.getInstance();
cal.set(dateTime.getYear(), dateTime.getMonthValue(), dateTime.getDayOfMonth(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond());
return cal;
}

private static Calendar toCalendar(@NotNull String date) {
DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
LocalDateTime dt = LocalDateTime.parse(date, formatter);
Calendar cal = Calendar.getInstance();
cal.set(dt.getYear(), dt.getMonthValue(), dt.getDayOfMonth(), dt.getHour(), dt.getMinute(), dt.getSecond());
return cal;
}


/**
* Parse date calendar.
*
* @param date
* the date
* @param dateFormat
* the date format
* The date in string format like (String dateString = "2016-12-16T12:36:33.961Z";)
* @param timeZone
* the time zone
* @return the calendar
* @throws ParseException
* the parse exception
* the time zone as string
* @return calendar @{@link Calendar}
*/
public static Calendar parseDate(String date, String dateFormat, TimeZone timeZone) throws ParseException {
Calendar cal = Calendar.getInstance();
SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
Date dateObject = dateFormatter.parse(date);
String month = new SimpleDateFormat("MM").format(dateObject);
String day = new SimpleDateFormat("dd").format(dateObject);
String year = new SimpleDateFormat("yyyy").format(dateObject);
String hourOfDay = new SimpleDateFormat("HH").format(dateObject);
String min = new SimpleDateFormat("mm").format(dateObject);
String sec = new SimpleDateFormat("ss").format(dateObject);

public static Calendar parseDate(@NotNull String date, TimeZone timeZone) {
// Use the ISO-8601 format to parse the date string
if (date.isEmpty()){
return null;
}
Calendar cal = toCalendar(date);
if (timeZone != null) {
cal.setTimeZone(timeZone);
} else {
cal.setTimeZone(TimeZone.getDefault());
}
cal.set(Integer.parseInt(year), Integer.parseInt(month) - 1, Integer.parseInt(day), Integer.parseInt(hourOfDay),
Integer.parseInt(min), Integer.parseInt(sec));
return cal;
}

3 changes: 3 additions & 0 deletions src/main/java/com/contentstack/sdk/ContentTypesCallback.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.contentstack.sdk;

/**
* The callback for Content Types that contains ContentTypesModel and Error
*/
public abstract class ContentTypesCallback implements ResultCallBack {

public abstract void onCompletion(ContentTypesModel contentTypesModel, Error error);
3 changes: 3 additions & 0 deletions src/main/java/com/contentstack/sdk/ContentTypesModel.java
Original file line number Diff line number Diff line change
@@ -3,6 +3,9 @@
import org.json.JSONArray;
import org.json.JSONObject;

/**
* The ContentTypesModel that contains content type response
*/
public class ContentTypesModel {

private Object response;
7 changes: 5 additions & 2 deletions src/main/java/com/contentstack/sdk/ContentstackPlugin.java
Original file line number Diff line number Diff line change
@@ -6,7 +6,10 @@

public interface ContentstackPlugin {

void onRequest(Stack stack, Request request);
default void onRequest(Stack stack, Request request) {
}

Response<ResponseBody> onResponse(Stack stack, Request request, Response response);
default Response<ResponseBody> onResponse(Stack stack, Request request, Response<ResponseBody> response) {
return response;
}
}
Loading