Skip to content

Commit 2ad1f58

Browse files
v1.10.2
1 parent 5d23c6e commit 2ad1f58

File tree

15 files changed

+587
-498
lines changed

15 files changed

+587
-498
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Authors
2+
23
- [ishaileshmishra](shailesh.mishra@contentstack.com)
34
- [shaileshmishra](mshaileshr@contentstack.com)
45
- [admin](dev@contentstack.com)

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# CHANGELOG
22

3+
## Version 1.10.2
4+
5+
### Date: 27-Oct-2022
6+
7+
- LivePreview internal function implementation updated
8+
- Jsoup dependency updated
9+
- Json version updated
10+
11+
---
12+
13+
## Version 1.10.1
14+
15+
### Date: 18-June-2022
16+
17+
- Compile Issue With Gradle
18+
19+
---
20+
321
## Version 1.10.0
422

523
### Date: 16-May-2022

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
43

54
<modelVersion>4.0.0</modelVersion>
65
<groupId>com.contentstack.sdk</groupId>

src/main/java/com/contentstack/sdk/CSBackgroundTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ protected CSBackgroundTask(Query queryInstance, Stack stackInstance, String cont
3636
csConnectionRequest.setQueryInstance(queryInstance);
3737
csConnectionRequest.setURLQueries(urlQueries);
3838
this.service = stackInstance.service;
39-
csConnectionRequest.setParams(completeUrl, headers, controller, requestInfo, callback, this.service, stackInstance.config);
39+
csConnectionRequest.setParams(completeUrl, headers, controller, requestInfo, callback, this.service,
40+
stackInstance.config);
4041

4142
}
4243

src/main/java/com/contentstack/sdk/CSConnectionPool.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import java.util.concurrent.TimeUnit;
66

7-
87
public class CSConnectionPool {
98

109
ConnectionPool create() {

src/main/java/com/contentstack/sdk/CSHttpConnection.java

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,9 @@ private void getService(String requestUrl) throws IOException {
189189
Response<ResponseBody> response = this.service.getRequest(requestUrl, this.headers).execute();
190190
if (response.isSuccessful()) {
191191
assert response.body() != null;
192-
// String resp = response.body().string();
193192
responseJSON = new JSONObject(response.body().string());
194193
// LivePreviewAgent to validate If LivePreview Response is there for mapping
195-
if (this.config.livePreviewEntry != null) {
194+
if (this.config.livePreviewEntry != null && !this.config.livePreviewEntry.isEmpty()) {
196195
livePreviewAgent();
197196
}
198197
connectionRequest.onRequestFinished(CSHttpConnection.this);
@@ -210,22 +209,48 @@ private void livePreviewAgent() {
210209
if (responseJSON.has("entry")) {
211210
mapLPreviewToEntry(responseJSON.optJSONObject("entry"), 0);
212211
}
213-
// TODO: responseJSON
214212
}
215213

216214
private void mapLPreviewToEntry(JSONObject entry, int idx) {
217-
System.out.println(entry);
218-
if (entry.opt("uid").equals(this.config.livePreviewEntry.opt("uid"))){
219-
System.out.println("Equal------");
215+
if (entry.opt("uid").equals(this.config.livePreviewEntry.opt("uid"))) {
216+
filterToUpdate(entry, idx);
220217
}
221218
}
222219

223-
private void mapLPreviewToQuery(JSONArray entries) {
224-
IntStream.range(0, entries.length())
225-
.forEach(idx -> mapLPreviewToEntry((JSONObject) entries.get(idx), idx)
226-
);
220+
// How to merge the JSONObject key value to another key?
221+
// JSONObject a = new JSONObject("{\"data\": [ {\"empId\": 1,\"deptId\":
222+
// 2},{\"empId\": 3,\"deptId\": 4}]}");
223+
// JSONObject b = new JSONObject("{\"data\": [ {\"empId\": 7,\"deptId\":
224+
// 8},{\"empId\": 9,\"deptId\": 10}]}");
225+
226+
// JSONArray jArr_A= a.getJSONArray("data");
227+
228+
// JSONArray jArr= new JSONArray();
229+
// for(int i=0;i<jArr_A.length();i++){
230+
// jArr.put(jArr_A.getJSONObject(i));
231+
// }
232+
233+
// jArr_A= b.getJSONArray("data");
234+
235+
// for(int i=0;i<jArr_A.length();i++){
236+
// jArr.put(jArr_A.getJSONObject(i));
237+
// }
238+
239+
// JSONObject mainJson = new JSONObject();
240+
// mainJson.put("data", jArr);
241+
242+
private void filterToUpdate(JSONObject entry, int idx) {
243+
JSONObject rec = responseJSON.optJSONArray("entries").getJSONObject(idx);
244+
if (rec.has("uid") && entry.opt("uid").equals(rec.opt("uid"))) {
245+
responseJSON.optJSONArray("entries").getJSONObject(idx).put(String.valueOf(entry), idx);
246+
// System.out.println();
247+
// TODO: Check again before commit.
248+
}
227249
}
228250

251+
private void mapLPreviewToQuery(JSONArray entries) {
252+
IntStream.range(0, entries.length()).forEach(idx -> mapLPreviewToEntry((JSONObject) entries.get(idx), idx));
253+
}
229254

230255
void setError(String errResp) {
231256
logger.info(errResp);

src/main/java/com/contentstack/sdk/Constants.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class Constants {
3737
protected static final String LIMIT = "limit";
3838
protected static final String OPTIONS = "$options";
3939

40-
4140
protected Constants() {
4241
logger.warning("Not Allowed");
4342
}
@@ -62,13 +61,15 @@ public enum REQUEST_CONTROLLER {
6261
public static final String CONTENT_TYPE_NAME = "Please set contentType name.";
6362
public static final String QUERY_EXCEPTION = "Please provide valid params.";
6463

64+
65+
6566
/**
6667
* Parse date calendar.
6768
*
6869
* @param date
69-
* the date
70+
* the date
7071
* @param timeZone
71-
* the time zone
72+
* the time zone
7273
* @return the calendar
7374
*/
7475
public static Calendar parseDate(String date, TimeZone timeZone) {
@@ -99,14 +100,14 @@ public static Calendar parseDate(String date, TimeZone timeZone) {
99100
* Parse date calendar.
100101
*
101102
* @param date
102-
* the date
103+
* the date
103104
* @param dateFormat
104-
* the date format
105+
* the date format
105106
* @param timeZone
106-
* the time zone
107+
* the time zone
107108
* @return the calendar
108109
* @throws ParseException
109-
* the parse exception
110+
* the parse exception
110111
*/
111112
public static Calendar parseDate(String date, String dateFormat, TimeZone timeZone) throws ParseException {
112113
Calendar cal = Calendar.getInstance();

src/main/java/com/contentstack/sdk/ContentType.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ protected void setStackInstance(Stack stack) {
3535
* Sets header on {@link Stack}.
3636
*
3737
* @param headerKey
38-
* the header key
38+
* the header key
3939
* @param headerValue
40-
* the header value
40+
* the header value
4141
*/
4242
public void setHeader(String headerKey, String headerValue) {
4343
if (!headerKey.isEmpty() && !headerValue.isEmpty()) {
@@ -49,7 +49,7 @@ public void setHeader(String headerKey, String headerValue) {
4949
* Remove header from {@link Stack}
5050
*
5151
* @param headerKey
52-
* the header key
52+
* the header key
5353
*/
5454
public void removeHeader(String headerKey) {
5555
if (!headerKey.isEmpty()) {
@@ -58,12 +58,13 @@ public void removeHeader(String headerKey) {
5858
}
5959

6060
/**
61-
* An entry is the actual piece of content created using one of the defined content types.
61+
* An entry is the actual piece of content created using one of the defined
62+
* content types.
6263
* <p>
6364
* The Get a single entry request fetches a particular entry of a content type.
6465
*
6566
* @param entryUid
66-
* the entry unique ID of the entry that you want to fetch.
67+
* the entry unique ID of the entry that you want to fetch.
6768
* @return the {@link Entry} entry.
6869
*/
6970
public Entry entry(String entryUid) {
@@ -81,8 +82,10 @@ protected Entry entry() {
8182
}
8283

8384
/**
84-
* Query. The Get all entries request fetches the list of all the entries of a particular content type. It returns
85-
* the content of each entry in JSON format. You need to specify the environment and locale of which you want to get
85+
* Query. The Get all entries request fetches the list of all the entries of a
86+
* particular content type. It returns
87+
* the content of each entry in JSON format. You need to specify the environment
88+
* and locale of which you want to get
8689
* the entries.
8790
*
8891
* <p>
@@ -94,10 +97,14 @@ protected Entry entry() {
9497
* language itself, this parameter would not be applicable.
9598
*
9699
* <p>
97-
* To include the publishing details in the response, make use of the include_publish_details=true parameter. This
98-
* will return the publishing details of the entry in every environment along with the version number that is
99-
* published in each of the environments. You can add other Queries to extend the functionality of this API call.
100-
* Add a query parameter named query and provide your query (in JSON format) as the value.
100+
* To include the publishing details in the response, make use of the
101+
* include_publish_details=true parameter. This
102+
* will return the publishing details of the entry in every environment along
103+
* with the version number that is
104+
* published in each of the environments. You can add other Queries to extend
105+
* the functionality of this API call.
106+
* Add a query parameter named query and provide your query (in JSON format) as
107+
* the value.
101108
*
102109
* @return the {@link Query}
103110
*/
@@ -112,9 +119,9 @@ public Query query() {
112119
* Fetch.
113120
*
114121
* @param params
115-
* the params
122+
* the params
116123
* @param callback
117-
* the callback
124+
* the callback
118125
*/
119126
public void fetch(@NotNull JSONObject params, final ContentTypesCallback callback) {
120127
String urlString = "content_types/" + contentTypeUid;
@@ -136,7 +143,7 @@ public void fetch(@NotNull JSONObject params, final ContentTypesCallback callbac
136143
}
137144

138145
private void fetchContentTypes(String urlString, JSONObject params, HashMap<String, Object> headers,
139-
ContentTypesCallback callback) {
146+
ContentTypesCallback callback) {
140147
if (callback != null) {
141148
HashMap<String, Object> urlParams = getUrlParams(params);
142149
new CSBackgroundTask(this, stackInstance, Constants.FETCHCONTENTTYPES, urlString, headers, urlParams,

0 commit comments

Comments
 (0)