Skip to content

Commit 0a084d9

Browse files
🔒 all cleaned
1 parent b0ea035 commit 0a084d9

Some content is hidden

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

65 files changed

+12201
-0
lines changed

README.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
2+
3+
## Contentstack Management Java SDK
4+
5+
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. All you have to do is build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).
6+
7+
This SDK uses the [Content Management API](https://www.contentstack.com/docs/developers/apis/content-management-api/) (CMA). The CMA is used to manage the content of your Contentstack account. This includes creating, updating, deleting, and fetching content of your account. To use the CMA, you will need to authenticate your users with a [Management Token](https://www.contentstack.com/docs/developers/create-tokens/about-management-tokens) or an [Authtoken](https://www.contentstack.com/docs/developers/apis/content-management-api/#how-to-get-authtoken). Read more about it in [Authentication](https://www.contentstack.com/docs/developers/apis/content-management-api/#authentication).
8+
9+
Note: By using CMA, you can execute GET requests for fetching content. However, we strongly recommend that you always use the [Content Delivery API](https://www.contentstack.com/docs/developers/apis/content-delivery-api/) to deliver content to your web or mobile properties.
10+
11+
### Prerequisite
12+
13+
You need Java 1.8 or above installed on your machine to use the Contentstack Java CMA SDK.
14+
15+
### Installation
16+
17+
Install it via maven:
18+
19+
```java
20+
<dependency>
21+
<groupId>com.contentstack</groupId>
22+
<artifactId>cms</artifactId>
23+
<version>{version}</version>
24+
</dependency>
25+
```
26+
27+
Install it via gradle:
28+
29+
```java
30+
implementation 'com.contentstack.sdk:1.0.0'
31+
```
32+
33+
Get updated version from [here](https://search.maven.org/artifact/com.contentstack.cms)
34+
35+
To import the SDK, use the following command:
36+
37+
```java
38+
import com.contentstack.cms.Contentstack;
39+
40+
Contentstack client = new Contentstack.Builder().build();
41+
```
42+
43+
### Authentication
44+
45+
To use this SDK, you need to authenticate your users by using the Authtoken, credentials, or Management Token (stack-level token).
46+
47+
### Authtoken
48+
49+
An [Authtoken](https://www.contentstack.com/docs/developers/create-tokens/types-of-tokens/#authentication-tokens-authtokens-) is a read-write token used to make authorized CMA requests, and it is a **user-specific** token.
50+
51+
```java
52+
Contentstack client = new Contentstack.Builder().setAuthtoken(AUTHTOKEN).build();
53+
```
54+
55+
### Login
56+
57+
To Login to Contentstack by using credentials, you can use the following lines of code:
58+
59+
```java
60+
Contentstack client = new Contentstack.Builder().setAuthtoken(AUTHTOKEN).build();
61+
Response<ResponseBody> response = client.login("EMAIL", "PASSWORD").execute()
62+
```
63+
64+
### Management Token
65+
66+
[Management Tokens](https://www.contentstack.com/docs/developers/create-tokens/about-management-tokens/) are **stack-level** tokens, with no users attached to them.
67+
68+
```java
69+
Contentstack client = new Contentstack.Builder().setAuthtoken(AUTHTOKEN).build();
70+
Response<ResponseBody> response = client.stack("API_KEY", "MANAGEMENT_TOKEN").contentType().execute()
71+
```
72+
73+
### Contentstack Management Java SDK: 5-minute Quickstart
74+
75+
#### Initializing Your SDK
76+
77+
To use the Java CMA SDK, you need to first initialize it. To do this, use the following code:
78+
79+
```java
80+
import com.contentstack.cms.Contentstack
81+
82+
Contentstack client = new Contentstack.Builder().setAuthtoken(AUTHTOKEN).build();
83+
```
84+
85+
#### Fetch Stack Detail
86+
87+
Use the following lines of code to fetch your stack detail using this SDK:
88+
89+
```java
90+
Contentstack client = new Contentstack.Builder().setAuthtoken(AUTHTOKEN).build();
91+
Response<ResponseBody> response = client.stack("API_KEY").exceute()
92+
```
93+
94+
#### Create Entry
95+
96+
To create an entry in a specific content type of a stack, use the following lines of code:
97+
98+
```java
99+
Under development
100+
```
101+
102+
#### Create Asset
103+
104+
The following lines of code can be used to upload assets to your stack:
105+
106+
```java
107+
Under development
108+
```
109+
110+
#### Create JSON Body
111+
112+
JSON Body could be created by using Map passing in the JSONObject or directly create JSONObject.
113+
Let's suppose you have to make json like below:
114+
115+
```java
116+
{
117+
"entry": {
118+
"title": "example",
119+
"url": "/example"
120+
}
121+
}
122+
```
123+
124+
Create request body like below:
125+
126+
```java
127+
HashMap<String, Object> mapBody = new HashMap<>();
128+
HashMap<String, Object> bodyContent = new HashMap<>();
129+
bodyContent.put("title", "example");
130+
bodyContent.put("url", "/example");
131+
requestBody.put("entry", bodyContent);
132+
133+
JSONObject requestBody = new JSONObject(mapBody)
134+
```
135+
136+
or
137+
Create using JSONObject like directly:
138+
139+
```java
140+
JSONObject requestBody = new JSONObject();
141+
JSONObject bodyContent = new JSONObject();
142+
bodyContent.put("title", "example");
143+
bodyContent.put("url", "/example");
144+
requestBody.put("entry", bodyContent);
145+
```
146+
147+
### Helpful Links
148+
149+
- [Contentstack Website](https://www.contentstack.com/)
150+
- [Official Documentation](https://contentstack.com/docs)
151+
- [Content Management API Docs](https://www.contentstack.com/docs/developers/apis/content-management-api)
152+
153+
### The MIT License (MIT)
154+
155+
Copyright © 2012-2022 [Contentstack](https://www.contentstack.com/). All Rights Reserved
156+
157+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
158+
159+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
160+
161+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)