Skip to content

Commit 585cfd4

Browse files
Merge pull request #96 from contentstack/CS-42935/feat-taxonomy-and-eaf
Cs 42935/feat taxonomy and eah
2 parents fe9482e + 663dacc commit 585cfd4

File tree

15 files changed

+784
-353
lines changed

15 files changed

+784
-353
lines changed

CHANGELOG.md

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

3+
## v1.13.0
4+
5+
### Date: 18-Dec-2023
6+
7+
- Taxonomy Query Support
8+
- Updated Latest version of Utils SDK to 1.2.6
9+
- Snyk Issues fixed
10+
- Updated dependencies
11+
- Added support for early access feature
12+
13+
314
## v1.12.3
415

516
### Date: 28-SEP-2023

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.contentstack.sdk</groupId>
77
<artifactId>java</artifactId>
8-
<version>1.12.3</version>
8+
<version>1.13.0</version>
99
<packaging>jar</packaging>
1010
<name>contentstack-java</name>
1111
<description>Java SDK for Contentstack Content Delivery API</description>
@@ -25,18 +25,18 @@
2525
<loggin.version>5.0.0-alpha.11</loggin.version>
2626
<jococo-plugin.version>0.8.5</jococo-plugin.version>
2727
<lombok-source.version>1.18.30</lombok-source.version>
28-
<junit-jupiter.version>5.10.0</junit-jupiter.version>
28+
<junit-jupiter.version>5.10.1</junit-jupiter.version>
2929
<junit-jupiter-engine.version>5.8.0-M1</junit-jupiter-engine.version>
3030
<gson.version>2.8.8</gson.version>
3131
<json-simple-version>1.1.1</json-simple-version>
3232
<maven-site-plugin.version>3.3</maven-site-plugin.version>
3333
<maven-gpg-plugin.version>1.5</maven-gpg-plugin.version>
3434
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
3535
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
36-
<json-version>20230618</json-version>
36+
<json-version>20231013</json-version>
3737
<jacoco-maven-plugin-version>0.8.7</jacoco-maven-plugin-version>
3838
<maven-release-plugin-version>2.5.3</maven-release-plugin-version>
39-
<contentstack-utils-version>1.2.4</contentstack-utils-version>
39+
<contentstack-utils-version>1.2.6</contentstack-utils-version>
4040
</properties>
4141

4242
<parent>

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import retrofit2.Call;
55
import retrofit2.http.GET;
66
import retrofit2.http.HeaderMap;
7+
import retrofit2.http.Query;
78
import retrofit2.http.Url;
89

910
import java.util.LinkedHashMap;
11+
import java.util.Map;
1012

1113
/**
1214
* @author Shailesh Mishra
@@ -15,5 +17,11 @@
1517
*/
1618
public interface APIService {
1719
@GET
18-
Call<ResponseBody> getRequest(@Url String url, @HeaderMap LinkedHashMap<String, Object> headers);
20+
Call<ResponseBody> getRequest(
21+
@Url String url, @HeaderMap LinkedHashMap<String, Object> headers);
22+
23+
@GET("v3/taxonomies/entries")
24+
Call<ResponseBody> getTaxonomy(
25+
@HeaderMap Map<String, Object> headers,
26+
@Query("query") String query);
1927
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ public void send() {
186186
}
187187

188188
private void getService(String requestUrl) throws IOException {
189-
this.headers.put(X_USER_AGENT_KEY, "contentstack-java/" + SDK_VERSION);
189+
190+
this.headers.put(X_USER_AGENT_KEY, "contentstack-delivery-java/" + SDK_VERSION);
190191
this.headers.put(USER_AGENT_KEY, USER_AGENT);
191192
this.headers.put(CONTENT_TYPE, APPLICATION_JSON);
192193

@@ -260,7 +261,6 @@ void handleJSONObject(JSONArray arrayEntry, JSONObject jsonObj, int idx) {
260261
}
261262

262263
void setError(String errResp) {
263-
logger.info(errResp);
264264
responseJSON = new JSONObject(errResp); // Parse error string to JSONObject
265265
responseJSON.put(ERROR_MESSAGE, responseJSON.optString(ERROR_MESSAGE));
266266
responseJSON.put(ERROR_CODE, responseJSON.optString(ERROR_CODE));

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

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class Config {
2121
protected String version = "v3";
2222
protected String scheme = "https://";
2323
protected String endpoint;
24+
protected String[] earlyAccess;
2425
protected boolean enableLivePreview = false;
2526
protected String livePreviewHost;
2627
protected JSONObject livePreviewEntry = null;
@@ -32,6 +33,25 @@ public class Config {
3233

3334
protected List<ContentstackPlugin> plugins = null;
3435

36+
37+
/**
38+
* Get early access
39+
* @return array of String
40+
*/
41+
public String[] getEarlyAccess() {
42+
return this.earlyAccess;
43+
}
44+
45+
/**
46+
* Get early access
47+
* @param earlyAccess type of String[]
48+
* @return instance of {@link Config}
49+
*/
50+
public Config setEarlyAccess(String[] earlyAccess) {
51+
this.earlyAccess = earlyAccess;
52+
return this;
53+
}
54+
3555
public String getBranch() {
3656
return branch;
3757
}
@@ -43,17 +63,16 @@ public void setBranch(String branch) {
4363
/**
4464
* Proxy can be set like below.
4565
*
46-
* @param proxy
47-
* Proxy setting, typically a type (http, socks) and a socket address. A Proxy is an immutable object
48-
* <br>
49-
* <br>
50-
* <b>Example:</b><br>
51-
* <br>
52-
* <code>
53-
* java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", "proxyPort"));
54-
* java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("sl.theproxyvpn.io", 80)); Config
55-
* config = new Config(); config.setProxy(proxy);
56-
* </code>
66+
* @param proxy Proxy setting, typically a type (http, socks) and a socket address. A Proxy is an immutable object
67+
* <br>
68+
* <br>
69+
* <b>Example:</b><br>
70+
* <br>
71+
* <code>
72+
* java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", "proxyPort"));
73+
* java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("sl.theproxyvpn.io", 80)); Config
74+
* config = new Config(); config.setProxy(proxy);
75+
* </code>
5776
*/
5877
public void setProxy(Proxy proxy) {
5978
this.proxy = proxy;
@@ -73,12 +92,9 @@ public Proxy getProxy() {
7392
* {@link okhttp3.Address} may share a {@link okhttp3.Connection}. This class implements the policy * of which
7493
* connections to keep open for future use.
7594
*
76-
* @param maxIdleConnections
77-
* the maxIdleConnections default value is 5
78-
* @param keepAliveDuration
79-
* the keepAliveDuration default value is 5
80-
* @param timeUnit
81-
* the timeUnit default value is TimeUnit. MINUTES
95+
* @param maxIdleConnections the maxIdleConnections default value is 5
96+
* @param keepAliveDuration the keepAliveDuration default value is 5
97+
* @param timeUnit the timeUnit default value is TimeUnit. MINUTES
8298
* @return ConnectionPool
8399
*/
84100
public ConnectionPool connectionPool(int maxIdleConnections, long keepAliveDuration, TimeUnit timeUnit) {
@@ -98,8 +114,7 @@ public ContentstackRegion getRegion() {
98114
/**
99115
* Sets region.
100116
*
101-
* @param region
102-
* the region
117+
* @param region the region
103118
* @return the region
104119
*/
105120
public ContentstackRegion setRegion(ContentstackRegion region) {
@@ -131,8 +146,7 @@ public String getHost() {
131146
/**
132147
* Sets host.
133148
*
134-
* @param hostName
135-
* the host name
149+
* @param hostName the host name
136150
*/
137151
public void setHost(String hostName) {
138152
if (hostName != null && !hostName.isEmpty()) {
@@ -152,8 +166,7 @@ public String getVersion() {
152166
/**
153167
* Enable live preview config.
154168
*
155-
* @param enableLivePreview
156-
* to enable live preview
169+
* @param enableLivePreview to enable live preview
157170
* @return the config
158171
*/
159172
public Config enableLivePreview(boolean enableLivePreview) {
@@ -164,8 +177,7 @@ public Config enableLivePreview(boolean enableLivePreview) {
164177
/**
165178
* Sets live preview host.
166179
*
167-
* @param livePreviewHost
168-
* the live preview host
180+
* @param livePreviewHost the live preview host
169181
* @return the live preview host
170182
*/
171183
public Config setLivePreviewHost(@NotNull String livePreviewHost) {
@@ -181,8 +193,7 @@ protected Config setLivePreviewEntry(@NotNull JSONObject livePreviewEntry) {
181193
/**
182194
* Sets management token.
183195
*
184-
* @param managementToken
185-
* the management token
196+
* @param managementToken the management token
186197
* @return the management token
187198
*/
188199
public Config setManagementToken(@NotNull String managementToken) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
public class Constants {
2222

2323
private static final Logger logger = Logger.getLogger(Constants.class.getSimpleName());
24-
protected static final String SDK_VERSION = "1.12.3";
24+
protected static final String SDK_VERSION = "1.13.0";
2525
protected static final String ENVIRONMENT = "environment";
2626
protected static final String CONTENT_TYPE_UID = "content_type_uid";
2727
protected static final String ENTRY_UID = "entry_uid";

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

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
public class Contentstack {
1919

20-
// Modifier Protected
2120
protected Contentstack() throws IllegalAccessException {
2221
throw new IllegalAccessException("Can Not Access Private Modifier");
2322
}
@@ -31,27 +30,22 @@ protected Contentstack() throws IllegalAccessException {
3130
* key of your stack. <br>
3231
* Find Your Stack Credentials from Contentstack .
3332
*
34-
* @param stackApiKey
35-
* The API Key is a unique key assigned to each stack.
36-
* @param deliveryToken
37-
* The Delivery Token is a read-only credential that you
33+
* @param stackApiKey The API Key is a unique key assigned to each stack.
34+
* @param deliveryToken The Delivery Token is a read-only credential that you
3835
* can create for different environments of your
3936
* stack
40-
* @param environment
41-
* the environment for the stack
37+
* @param environment the environment for the stack
4238
* @return the stack
43-
* @throws IllegalAccessException
44-
* the illegal access exception
45-
* <p>
46-
* <b>Example</b>
47-
*
48-
* <pre>
49-
* {
50-
* &#64;Code
51-
* Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
52-
* }
39+
* @throws IllegalAccessException the illegal access exception
40+
* <p>
41+
* <b>Example</b>
5342
*
54-
* </pre>
43+
* <pre>
44+
* {
45+
* &#64;Code
46+
* Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
47+
* }
48+
* </pre>
5549
*/
5650
public static Stack stack(String stackApiKey, String deliveryToken, String environment)
5751
throws IllegalAccessException {
@@ -66,21 +60,16 @@ public static Stack stack(String stackApiKey, String deliveryToken, String envir
6660
* create content structures, content entries, users, etc. related to the
6761
* project.
6862
*
69-
* @param stackApiKey
70-
* The API Key is a unique key assigned to each stack.
71-
* @param deliveryToken
72-
* The Delivery Token is a read-only credential that you
63+
* @param stackApiKey The API Key is a unique key assigned to each stack.
64+
* @param deliveryToken The Delivery Token is a read-only credential that you
7365
* can create for different environments of your
7466
* stack
75-
* @param environment
76-
* the environment for the stack
77-
* @param config
78-
* the config
67+
* @param environment the environment for the stack
68+
* @param config the config
7969
* @return the stack
80-
* @throws IllegalAccessException
81-
* the illegal access exception <b>Example</b>
70+
* @throws IllegalAccessException the illegal access exception <b>Example</b>
8271
* <p>
83-
* { @Code Stack stack =
72+
* { @Code stack =
8473
* contentstack.Stack("apiKey", "deliveryToken",
8574
* "environment"); }
8675
*/
@@ -115,6 +104,10 @@ private static Stack initializeStack(String stackApiKey, String deliveryToken, S
115104
if (config.getBranch() != null && !config.getBranch().isEmpty()) {
116105
stack.setHeader("branch", config.getBranch());
117106
}
107+
if (config.getEarlyAccess() != null && config.getEarlyAccess().length > 0) {
108+
String eaValues = String.join(",", config.earlyAccess).replace("\"", "");
109+
stack.setHeader("x-header-ea", eaValues);
110+
}
118111
stack.setConfig(config);
119112
return stack;
120113
}

0 commit comments

Comments
 (0)