Skip to content

Commit e263041

Browse files
Merge pull request #97 from contentstack/next
Taxonomy and Early Access Header
2 parents 3509899 + 336f7bd commit e263041

14 files changed

+774
-354
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# CHANGELOG
22

3+
## v1.13.0
4+
5+
### Date: 17-Nov-2023
6+
7+
- Updated Latest version of Utils SDK to 1.2.6
8+
- Snyk Issues fixed
9+
- Updated dependencies
10+
- Added support for early access feature
11+
312
## v1.12.3
413

514
### Date: 28-SEP-2023

pom.xml

+8-7
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>
@@ -122,13 +122,14 @@
122122
<scope>compile</scope>
123123
</dependency>
124124

125+
<!-- https://mvnrepository.com/artifact/io.github.cdimascio/java-dotenv -->
125126
<dependency>
126127
<groupId>io.github.cdimascio</groupId>
127-
<artifactId>dotenv-java</artifactId>
128-
<version>${dotenv-source.version}</version>
129-
<!--<scope>runtime</scope>-->
128+
<artifactId>java-dotenv</artifactId>
129+
<version>5.2.2</version>
130130
</dependency>
131131

132+
132133
<dependency>
133134
<groupId>io.reactivex.rxjava3</groupId>
134135
<artifactId>rxjava</artifactId>

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

+9-1
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

+2-2
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

+29-27
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,21 @@ public class Config {
2828
protected String managementToken;
2929
protected String branch;
3030
protected Proxy proxy = null;
31+
protected String[] earlyAccess = null;
3132
protected ConnectionPool connectionPool = new ConnectionPool();
3233

3334
protected List<ContentstackPlugin> plugins = null;
3435

36+
37+
public String[] getEarlyAccess() {
38+
return this.earlyAccess;
39+
}
40+
41+
public Config setEarlyAccess(String[] earlyAccess) {
42+
this.earlyAccess = earlyAccess;
43+
return this;
44+
}
45+
3546
public String getBranch() {
3647
return branch;
3748
}
@@ -43,17 +54,16 @@ public void setBranch(String branch) {
4354
/**
4455
* Proxy can be set like below.
4556
*
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>
57+
* @param proxy Proxy setting, typically a type (http, socks) and a socket address. A Proxy is an immutable object
58+
* <br>
59+
* <br>
60+
* <b>Example:</b><br>
61+
* <br>
62+
* <code>
63+
* java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", "proxyPort"));
64+
* java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("sl.theproxyvpn.io", 80)); Config
65+
* config = new Config(); config.setProxy(proxy);
66+
* </code>
5767
*/
5868
public void setProxy(Proxy proxy) {
5969
this.proxy = proxy;
@@ -73,12 +83,9 @@ public Proxy getProxy() {
7383
* {@link okhttp3.Address} may share a {@link okhttp3.Connection}. This class implements the policy * of which
7484
* connections to keep open for future use.
7585
*
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
86+
* @param maxIdleConnections the maxIdleConnections default value is 5
87+
* @param keepAliveDuration the keepAliveDuration default value is 5
88+
* @param timeUnit the timeUnit default value is TimeUnit. MINUTES
8289
* @return ConnectionPool
8390
*/
8491
public ConnectionPool connectionPool(int maxIdleConnections, long keepAliveDuration, TimeUnit timeUnit) {
@@ -98,8 +105,7 @@ public ContentstackRegion getRegion() {
98105
/**
99106
* Sets region.
100107
*
101-
* @param region
102-
* the region
108+
* @param region the region
103109
* @return the region
104110
*/
105111
public ContentstackRegion setRegion(ContentstackRegion region) {
@@ -131,8 +137,7 @@ public String getHost() {
131137
/**
132138
* Sets host.
133139
*
134-
* @param hostName
135-
* the host name
140+
* @param hostName the host name
136141
*/
137142
public void setHost(String hostName) {
138143
if (hostName != null && !hostName.isEmpty()) {
@@ -152,8 +157,7 @@ public String getVersion() {
152157
/**
153158
* Enable live preview config.
154159
*
155-
* @param enableLivePreview
156-
* to enable live preview
160+
* @param enableLivePreview to enable live preview
157161
* @return the config
158162
*/
159163
public Config enableLivePreview(boolean enableLivePreview) {
@@ -164,8 +168,7 @@ public Config enableLivePreview(boolean enableLivePreview) {
164168
/**
165169
* Sets live preview host.
166170
*
167-
* @param livePreviewHost
168-
* the live preview host
171+
* @param livePreviewHost the live preview host
169172
* @return the live preview host
170173
*/
171174
public Config setLivePreviewHost(@NotNull String livePreviewHost) {
@@ -181,8 +184,7 @@ protected Config setLivePreviewEntry(@NotNull JSONObject livePreviewEntry) {
181184
/**
182185
* Sets management token.
183186
*
184-
* @param managementToken
185-
* the management token
187+
* @param managementToken the management token
186188
* @return the management token
187189
*/
188190
public Config setManagementToken(@NotNull String managementToken) {

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

+1-1
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

+18-23
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,23 @@ protected Contentstack() throws IllegalAccessException {
3131
* key of your stack. <br>
3232
* Find Your Stack Credentials from Contentstack .
3333
*
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
34+
* @param stackApiKey The API Key is a unique key assigned to each stack.
35+
* @param deliveryToken The Delivery Token is a read-only credential that you
3836
* can create for different environments of your
3937
* stack
40-
* @param environment
41-
* the environment for the stack
38+
* @param environment the environment for the stack
4239
* @return the stack
43-
* @throws IllegalAccessException
44-
* the illegal access exception
40+
* @throws IllegalAccessException the illegal access exception
4541
* <p>
4642
* <b>Example</b>
4743
*
4844
* <pre>
49-
* {
50-
* &#64;Code
51-
* Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
52-
* }
45+
* {
46+
* &#64;Code
47+
* Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
48+
* }
5349
*
54-
* </pre>
50+
* </pre>
5551
*/
5652
public static Stack stack(String stackApiKey, String deliveryToken, String environment)
5753
throws IllegalAccessException {
@@ -66,19 +62,14 @@ public static Stack stack(String stackApiKey, String deliveryToken, String envir
6662
* create content structures, content entries, users, etc. related to the
6763
* project.
6864
*
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
65+
* @param stackApiKey The API Key is a unique key assigned to each stack.
66+
* @param deliveryToken The Delivery Token is a read-only credential that you
7367
* can create for different environments of your
7468
* stack
75-
* @param environment
76-
* the environment for the stack
77-
* @param config
78-
* the config
69+
* @param environment the environment for the stack
70+
* @param config the config
7971
* @return the stack
80-
* @throws IllegalAccessException
81-
* the illegal access exception <b>Example</b>
72+
* @throws IllegalAccessException the illegal access exception <b>Example</b>
8273
* <p>
8374
* { @Code Stack stack =
8475
* contentstack.Stack("apiKey", "deliveryToken",
@@ -115,6 +106,10 @@ private static Stack initializeStack(String stackApiKey, String deliveryToken, S
115106
if (config.getBranch() != null && !config.getBranch().isEmpty()) {
116107
stack.setHeader("branch", config.getBranch());
117108
}
109+
if (config.getEarlyAccess() != null && config.getEarlyAccess().length > 0) {
110+
String eaValues = String.join(",", config.earlyAccess).replace("\"", "");
111+
stack.setHeader("x-header-ea", eaValues);
112+
}
118113
stack.setConfig(config);
119114
return stack;
120115
}

0 commit comments

Comments
 (0)