Skip to content

Commit dc5e95b

Browse files
docs updated
1 parent 88f5d76 commit dc5e95b

17 files changed

+298
-234
lines changed

README.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@ You need Java 8 or above installed on your machine to use the Contentstack Manag
2424

2525
### Installation
2626

27-
Install it via maven:
27+
**Install it via maven:**
2828

2929
```java
3030
<dependency>
31-
<groupId>com.contentstack.sdk</groupId>
32-
<artifactId>cms</artifactId>
33-
<version>{version}</version>
31+
<groupId>com.contentstack.sdk</groupId>
32+
<artifactId>cms</artifactId>
33+
<version>{version}</version>
3434
</dependency>
3535
```
3636

37-
Install it via gradle:
37+
**Install it via gradle:**
3838

3939
```java
40-
implementation'com.contentstack.sdk:cms:{version}'
40+
implementation'com.contentstack.sdk:cms:{version}'
4141
```
4242

4343
To import the SDK, use the following command:
4444

4545
```java
46-
package com.contentstack.cms;
47-
Contentstack contentstack=new Contentstack.Builder().build();
46+
package com.contentstack.cms;
47+
Contentstack contentstack = new Contentstack.Builder().build();
4848
```
4949

5050
### Authentication
@@ -58,16 +58,16 @@ An [Authtoken](https://www.contentstack.com/docs/developers/create-tokens/types-
5858
is a read-write token used to make authorized CMA requests, and it is a **user-specific** token.
5959

6060
```java
61-
Contentstack contentstack=new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
61+
Contentstack contentstack = new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
6262
```
6363

6464
### Login
6565

6666
To Login to Contentstack by using credentials, you can use the following lines of code:
6767

6868
```java
69-
Contentstack contentstack=new Contentstack.Builder().build();
70-
contentstack.login("EMAIL","PASSWORD");
69+
Contentstack contentstack = new Contentstack.Builder().build();
70+
contentstack.login("EMAIL","PASSWORD");
7171
```
7272

7373
### Management Token
@@ -76,8 +76,8 @@ To Login to Contentstack by using credentials, you can use the following lines o
7676
*stack-level** tokens, with no users attached to them.
7777

7878
```java
79-
Contentstack contentstack=new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
80-
Stack stack=contentstack.stack("API_KEY","MANAGEMENT_TOKEN");
79+
Contentstack contentstack = new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
80+
Stack stack=contentstack.stack("API_KEY","MANAGEMENT_TOKEN");
8181
```
8282

8383
### Contentstack Management Java SDK: 5-minute Quickstart
@@ -87,52 +87,52 @@ To Login to Contentstack by using credentials, you can use the following lines o
8787
To use the Java CMA SDK, you need to first initialize it. To do this, use the following code:
8888

8989
```java
90-
Contentstack contentstack=new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
90+
Contentstack contentstack = new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
9191
```
9292

9393
#### Fetch Stack Detail
9494

9595
Use the following lines of code to fetch your stack detail using this SDK:
9696

9797
```java
98-
Stack stack=contentstack.stack("API_KEY");
99-
Response<ResponseBody> response=stack.fetch().execute();
98+
Stack stack = contentstack.stack("API_KEY");
99+
Response<ResponseBody> response = stack.fetch().execute();
100100
```
101101

102102
#### Create Entry
103103

104104
To create an entry in a specific content type of a stack, use the following lines of code:
105105

106106
```java
107-
Contentstack contentstack=new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
108-
Stack stack=contentstack.stack("API_KEY");
109-
JSONObject body=....
110-
Response<ResponseBody> response=entry.create(body).execute();
111-
if(response.isSuccessful()){
112-
System.out.println(response.body());
113-
}
107+
Contentstack contentstack = new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
108+
Stack stack=contentstack.stack("API_KEY");
109+
JSONObject body = ....
110+
Response<ResponseBody> response=entry.create(body).execute();
111+
if(response.isSuccessful()){
112+
System.out.println(response.body());
113+
}
114114
```
115115

116116
#### Create Asset
117117

118118
The following lines of code can be used to upload assets to your stack:
119119

120120
```java
121-
Contentstack contentstack=new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
122-
Stack stack=contentstack.stack("API_KEY");
123-
Asset asset=stack.asset();
124-
Response<ResponseBody> response=asset.uploadAsset("filePath","description").execute();
125-
if(response.isSuccessful()){
126-
System.out.println(response.body());
127-
}else{
128-
System.out.println(response.errorBody());
129-
}
121+
Contentstack contentstack = new Contentstack.Builder().setAuthtoken("AUTHTOKEN").build();
122+
Stack stack=contentstack.stack("API_KEY");
123+
Asset asset=stack.asset();
124+
Response<ResponseBody> response=asset.uploadAsset("filePath","description").execute();
125+
if(response.isSuccessful()){
126+
System.out.println(response.body());
127+
}else{
128+
System.out.println(response.errorBody());
129+
}
130130
```
131131

132132
### Helpful Links
133133

134134
- [Contentstack Website](https://www.contentstack.com/)
135-
- [Official Documentation](https://contentstack.com/docs)
135+
- [API Reference Documentation](https://www.contentstack.com/docs/developers/sdks/content-management-sdk/java)
136136
- [Content Management API Docs](https://www.contentstack.com/docs/developers/apis/content-management-api)
137137

138138
### The MIT License (MIT)

changelog.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22

33
## v1.0.0
44

5-
### 30-June-2023
6-
5+
### Jul 12, 2023
76
- Bug Fixed For Unlocalize An Entry
87
- Fixed Timeout Issue
9-
- General improvements with minor breaking changes
108
- Code coverage improvements
119
- NRP support added
12-
-
10+
- General improvements with minor breaking changes
1311

1412
## v0.1.0
1513

1614
### Initial Release
1715

18-
### 20-OCT-2022
19-
16+
### Oct 20, 2022
2017
Initial release for Contentstack CMA base Java management SDK

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</developer>
6161
</developers>
6262

63-
<distributionManagement>
63+
<!-- <distributionManagement>
6464
<snapshotRepository>
6565
<id>ossrh</id>
6666
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
@@ -69,7 +69,7 @@
6969
<id>ossrh</id>
7070
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
7171
</repository>
72-
</distributionManagement>
72+
</distributionManagement> -->
7373

7474
<properties>
7575
<sdk.version>0.1.0-SNAPSHOT</sdk.version>

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,46 @@
2424
*/
2525
public class AuthInterceptor implements Interceptor {
2626

27+
protected String authtoken;
28+
29+
// The `public AuthInterceptor() {}` is a default constructor for the
30+
// `AuthInterceptor` class. It is
31+
// used to create an instance of the `AuthInterceptor` class without passing any
32+
// arguments. In this
33+
// case, it initializes the `authtoken` variable to `null`.
2734
public AuthInterceptor() {
2835
}
2936

30-
protected String authtoken;
31-
37+
// The `public AuthInterceptor(String authtoken)` is a constructor for the
38+
// `AuthInterceptor` class that
39+
// takes an `authtoken` parameter.
3240
public AuthInterceptor(String authtoken) {
3341
this.authtoken = authtoken;
3442
}
3543

44+
/**
45+
* The function sets the value of the authtoken variable.
46+
*
47+
* @param authtoken The authtoken parameter is a string that represents an
48+
* authentication token.
49+
*/
3650
public void setAuthtoken(String authtoken) {
3751
this.authtoken = authtoken;
3852
}
3953

54+
/**
55+
* This function intercepts a request and adds headers to it, including a user
56+
* agent, content type, and
57+
* authentication token if available.
58+
*
59+
* @param chain The `chain` parameter is an object of type `Interceptor.Chain`.
60+
* It represents the chain
61+
* of interceptors that will be executed for a given request. It
62+
* provides methods to proceed to the
63+
* next interceptor in the chain or to proceed with the request and
64+
* get the response.
65+
* @return The method is returning a Response object.
66+
*/
4067
@NotNull
4168
@Override
4269
public Response intercept(Chain chain) throws IOException {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ public BadArgumentException() {
1414
super();
1515
}
1616

17+
// The code `public BadArgumentException(String message) { super(message); }` is
18+
// a constructor for the
19+
// `BadArgumentException` class. It takes a `String` parameter `message` and
20+
// calls the constructor of
21+
// the superclass `IllegalArgumentException` with the `message` parameter. This
22+
// allows you to create an
23+
// instance of `BadArgumentException` with a custom error message.
1724
public BadArgumentException(String message) {
1825
super(message);
1926
}

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,78 @@ public class CMALogger {
1515

1616
private final Logger logger;
1717

18+
/**
19+
* The function returns the logger object.
20+
*
21+
* @return The method is returning an instance of the Logger class.
22+
*/
1823
public Logger getLogger() {
1924
return logger;
2025
}
2126

27+
// The `CMALogger` constructor is used to create an instance of the `CMALogger`
28+
// class. It takes a
29+
// parameter `className` of type `Class<?>` (any class) and initializes the
30+
// `logger` object using the
31+
// `getLogger` method of the `Logger` class. The `getLogger` method takes the
32+
// simple name of the
33+
// `className` and returns an instance of the `Logger` class. The `@NotNull`
34+
// annotation indicates that
35+
// the `className` parameter cannot be null.
2236
public CMALogger(@NotNull Class<?> className) {
2337
logger = Logger.getLogger(className.getSimpleName());
2438
}
2539

40+
// The `info` method in the `CMALogger` class is used to log a message at an
41+
// informational level of
42+
// detail using the logger. It takes a `String` parameter named `message` and
43+
// logs the message using
44+
// the `info` method of the logger.
45+
// The `info` method in the `CMALogger` class is used to log a message at an
46+
// informational level of
47+
// detail using the logger. It takes a `String` parameter named `message` and
48+
// logs the message
49+
// using the `info` method of the logger. The `@NotNull` annotation indicates
50+
// that the `message`
51+
// parameter cannot be null.
2652
public void info(@NotNull String message) {
2753
logger.info(message);
2854
}
2955

56+
// The `fine` method in the `CMALogger` class is used to log a message at a fine
57+
// level of detail using
58+
// the logger. It takes a `String` parameter named `message` and logs the
59+
// message using the `info`
60+
// method of the logger.
3061
public void fine(@NotNull String message) {
3162
logger.info(message);
3263
}
3364

65+
// The `finer` method in the `CMALogger` class is used to log a message at a
66+
// finer level of detail
67+
// using the logger. It takes a `String` parameter named `message` and logs the
68+
// message using the
69+
// `finer` method of the logger.
3470
public void finer(@NotNull String message) {
3571
logger.finer(message);
3672
}
3773

74+
/**
75+
* The function "warning" logs a warning message using a logger.
76+
*
77+
* @param message A string parameter named "message" which is annotated with the
78+
* "@NotNull" annotation.
79+
*/
3880
public void warning(@NotNull String message) {
3981
logger.warning(message);
4082
}
4183

84+
/**
85+
* The function "severe" logs a severe-level message using a logger.
86+
*
87+
* @param message A string parameter named "message" which is annotated with the
88+
* "@NotNull" annotation.
89+
*/
4290
public void severe(@NotNull String message) {
4391
logger.severe(message);
4492
}

0 commit comments

Comments
 (0)