Skip to content

Commit 93e5684

Browse files
Merge pull request #10 from contentstack/dev
support of branch and alias added
2 parents a3d118e + ffd9de0 commit 93e5684

File tree

76 files changed

+3234
-1132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3234
-1132
lines changed

pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.contentstack.sdk</groupId>
66
<artifactId>cms</artifactId>
7+
<packaging>jar</packaging>
78
<name>contentstack-management-java</name>
8-
<version>1.0.0-SNAPSHOT</version>
9+
<version>1.0.0-alpha-SNAPSHOT</version>
910
<description>Contentstack Java Management SDK for Content Management API, Contentstack is a headless CMS with an
1011
API-first approach
1112
</description>
1213
<url>https://github.com/contentstack/contentstack-management-java/</url>
1314

15+
<!-- release the package using mvn clean deploy -->
1416
<parent>
1517
<groupId>org.sonatype.oss</groupId>
1618
<artifactId>oss-parent</artifactId>
@@ -167,6 +169,17 @@
167169

168170
<build>
169171
<plugins>
172+
173+
<!--mvn clean install -U -Dmaven.test.failure.ignore=true-->
174+
<plugin>
175+
<groupId>org.apache.maven.plugins</groupId>
176+
<artifactId>maven-surefire-plugin</artifactId>
177+
<version>3.0.0-M5</version>
178+
<configuration>
179+
<testFailureIgnore>true</testFailureIgnore>
180+
</configuration>
181+
</plugin>
182+
170183
<plugin>
171184
<groupId>org.apache.maven.plugins</groupId>
172185
<artifactId>maven-jxr-plugin</artifactId>
@@ -200,6 +213,7 @@
200213
</executions>
201214
</plugin>
202215

216+
<!-- -overview "***REMOVED***tentstack/java/contentstack-management-java/src/main/overview.html" -bottom "<b>Copyright © 2012-2022 Contentstack </b><sup>TM</sup>"-->
203217
<plugin>
204218
<groupId>org.apache.maven.plugins</groupId>
205219
<artifactId>maven-javadoc-plugin</artifactId>

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

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1+
2+
/**
3+
* The top most package to access contentstack instance
4+
*/
15
package com.contentstack.cms;
26

37
import com.contentstack.cms.core.AuthInterceptor;
4-
import com.contentstack.cms.models.Error;
58
import com.contentstack.cms.core.Util;
9+
import com.contentstack.cms.models.Error;
610
import com.contentstack.cms.models.LoginDetails;
711
import com.contentstack.cms.organization.Organization;
812
import com.contentstack.cms.stack.Stack;
913
import com.contentstack.cms.user.User;
1014
import com.google.gson.Gson;
1115
import okhttp3.OkHttpClient;
1216
import okhttp3.ResponseBody;
17+
import okhttp3.logging.HttpLoggingInterceptor;
1318
import org.jetbrains.annotations.NotNull;
1419
import retrofit2.Response;
1520
import retrofit2.Retrofit;
1621
import retrofit2.converter.gson.GsonConverterFactory;
17-
import okhttp3.logging.HttpLoggingInterceptor;
1822

1923
import java.io.IOException;
2024
import java.net.Proxy;
@@ -25,7 +29,12 @@
2529
import static com.contentstack.cms.core.Util.*;
2630

2731
/**
28-
* The type Contentstack.
32+
* <b>Contentstack Java Management SDK</b>
33+
* <br>
34+
* <b>Contentstack Java Management SDK</b> interact with the Content Management APIs and allow you to create, update,
35+
* delete, and fetch content from your Contentstack account. They are read-write in nature.
36+
* <br>
37+
* You can use them to build your own apps and manage your content from Contentstack.
2938
*/
3039
public class Contentstack {
3140

@@ -63,7 +72,11 @@ public class Contentstack {
6372
* </pre>
6473
* <br>
6574
*
66-
* @return User user
75+
* @return User
76+
* @author ***REMOVED***
77+
* @see <a href="https://www.contentstack.com/docs/developers/apis/content-management-api/#users">User
78+
* </a>
79+
* @since 2022-05-19
6780
*/
6881
public User user() {
6982
if (this.authtoken == null)
@@ -103,12 +116,15 @@ public User user() {
103116
* <br>
104117
*
105118
* @param emailId
106-
* the email id
119+
* the email id of the user
107120
* @param password
108-
* the password
109-
* @return response the Response type of @{@link LoginDetails}
121+
* the password of the user
122+
* @return LoginDetails
110123
* @throws IOException
111-
* the io exception
124+
* the IOException
125+
* @author ***REMOVED***
126+
* @see <a href="https://www.contentstack.com/docs/developers/apis/content-management-api/#users">User
127+
* </a>
112128
*/
113129
public Response<LoginDetails> login(String emailId, String password) throws IOException {
114130
if (this.authtoken != null)
@@ -155,9 +171,16 @@ public Response<LoginDetails> login(String emailId, String password) throws IOEx
155171
* the password
156172
* @param tfaToken
157173
* the tfa token
158-
* @return response the Response type of @{@link LoginDetails} throws {@link IOException}
174+
* @return LoginDetails
159175
* @throws IOException
160176
* the io exception
177+
* @throws IOException
178+
* the IOException
179+
* @author ***REMOVED***
180+
* @see <a
181+
* href="https://www.contentstack.com/docs/developers/apis/content-management-api/#log-in-to-your-account">Login
182+
* your account
183+
* </a>
161184
*/
162185
public Response<LoginDetails> login(String emailId, String password, String tfaToken) throws IOException {
163186
if (this.authtoken != null)
@@ -264,7 +287,7 @@ public Organization organization() {
264287
public Stack stack() {
265288
if (this.authtoken == null)
266289
throw new IllegalStateException(ILLEGAL_USER);
267-
return new Stack(this.instance);
290+
return new Stack(this.instance, this.authtoken);
268291
}
269292

270293

@@ -288,7 +311,9 @@ public Stack stack() {
288311
*/
289312
public Stack stack(@NotNull Map<String, Object> header) {
290313
if (this.authtoken == null)
291-
throw new IllegalStateException(PLEASE_LOGIN);
314+
if (header.size() == 0) {
315+
throw new IllegalStateException(PLEASE_LOGIN);
316+
}
292317
return new Stack(this.instance, header);
293318
}
294319

@@ -398,9 +423,11 @@ public Builder() {
398423
* InetSocketAddress(proxyHost, proxyPort));
399424
* <br>
400425
* <pre>
401-
* Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("hostname", 433));
402-
* Contentstack contentstack = new Contentstack.Builder().setProxy(proxy).build();
403-
* </pre>
426+
* {
427+
* Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("hostname", 433));
428+
* Contentstack contentstack = new Contentstack.Builder().setProxy(proxy).build();
429+
* }
430+
* </pre>
404431
*
405432
* @param proxy
406433
* the proxy

src/main/java/com/contentstack/cms/core/CMSRuntimeException.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* @version 1.0.0
88
* @since 2022-05-19
99
*/
10-
public class CMSRuntimeException extends Exception {
11-
public CMSRuntimeException(String message) {
10+
public class CMSRuntimeException extends Exception { public CMSRuntimeException(String message) {
1211
super(message);
13-
}
14-
}
12+
}}

src/main/java/com/contentstack/cms/core/CSResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
import java.io.IOException;
1010
import java.util.Objects;
1111

12+
/**
13+
* Contentstack Response:
14+
*
15+
* @author ***REMOVED***
16+
* @version 1.0.0
17+
* @since 2022-05-19
18+
*/
19+
1220
public class CSResponse {
1321

1422
private static final String MODEL_NULL_CHECK = "model class == null";

src/main/java/com/contentstack/cms/core/ContentstackResponse.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public class ContentstackResponse<T> {
1919

2020
Call<ResponseBody> response;
2121

22-
2322
public Response<ResponseBody> fetch(Call<ResponseBody> response) {
2423
try {
2524
return response.execute();

src/main/java/com/contentstack/cms/core/ObjectModel.java

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/main/java/com/contentstack/cms/core/Util.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
/**
11-
* The Utility class that contains utility common functions
11+
* The utility class that contains utility common functions
1212
*
1313
* @author ***REMOVED***
1414
* @version 1.0.0
@@ -80,8 +80,7 @@ public static void assertionError() {
8080
}
8181

8282
public static RequestBody toRequestBody(String bodyString) {
83-
return RequestBody.create(MediaType.parse("application/json; charset=UTF-8"),
84-
bodyString);
83+
return RequestBody.create(MediaType.parse("application/json; charset=UTF-8"), bodyString);
8584
}
8685

8786
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Useful to access contentstack's core components
3+
*/
4+
package com.contentstack.cms.core;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Useful to access contentstack's models and pojo classes
3+
*/
4+
package com.contentstack.cms.models;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Useful to access contentstack's organizations
3+
*/
4+
package com.contentstack.cms.organization;

0 commit comments

Comments
 (0)