Skip to content

Commit fc362ad

Browse files
v1.0.0
Aug 01, 2023 - Bug Fixed For un-localize An Entry - Fixed Timeout Issue - #32 Fixed - Code coverage improvements - NRP support added - General improvements with minor breaking changes
1 parent ef5fe0d commit fc362ad

File tree

84 files changed

+3279
-3060
lines changed

Some content is hidden

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

84 files changed

+3279
-3060
lines changed

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
### Aug 01, 2023
66
- Bug Fixed For un-localize An Entry
77
- Fixed Timeout Issue
8-
- #32 Fixed issue of Asset upload does not allow specifying attributes
8+
- #32 Fixed
99
- Code coverage improvements
1010
- NRP support added
1111
- General improvements with minor breaking changes

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
<version>1.1.1</version>
172172
<scope>compile</scope>
173173
</dependency>
174+
174175
</dependencies>
175176

176177

src/main/java/com/contentstack/cms/organization/Organization.java

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import retrofit2.Retrofit;
88

99
import java.util.HashMap;
10+
import java.util.Objects;
1011

1112
/**
1213
* Organization is the top-level entity in the hierarchy of Contentstack,
@@ -24,12 +25,13 @@ public class Organization {
2425
protected HashMap<String, String> headers;
2526
protected HashMap<String, Object> params;
2627
private String organizationUid;
28+
final String ERROR_MSG = "OrganizationUid Can Not Be Null OR Empty";
29+
2730

2831
/**
2932
* Instantiates a new Organization.
3033
*
31-
* @param client
32-
* The retrofit client
34+
* @param client The retrofit client
3335
*/
3436
public Organization(Retrofit client) {
3537
this.headers = new HashMap<>();
@@ -40,10 +42,8 @@ public Organization(Retrofit client) {
4042
/**
4143
* Instantiates a new Organization.
4244
*
43-
* @param client
44-
* The retrofit client
45-
* @param uid
46-
* The uid of the organisation
45+
* @param client The retrofit client
46+
* @param uid The uid of the organisation
4747
*/
4848
public Organization(Retrofit client, String uid) {
4949
this.headers = new HashMap<>();
@@ -55,10 +55,8 @@ public Organization(Retrofit client, String uid) {
5555
/**
5656
* Sets header for the request
5757
*
58-
* @param key
59-
* header key for the request
60-
* @param value
61-
* header value for the request
58+
* @param key header key for the request
59+
* @param value header value for the request
6260
* return Organization the instance of Organization
6361
* @return Organization instance of organization
6462
*/
@@ -70,10 +68,8 @@ public Organization addHeader(@NotNull String key, @NotNull String value) {
7068
/**
7169
* Sets header for the request
7270
*
73-
* @param key
74-
* header key for the request
75-
* @param value
76-
* header value for the request
71+
* @param key header key for the request
72+
* @param value header value for the request
7773
* @return instance of Organization
7874
*/
7975
public Organization addParam(@NotNull String key, @NotNull Object value) {
@@ -84,7 +80,7 @@ public Organization addParam(@NotNull String key, @NotNull Object value) {
8480
/**
8581
* The function clears the parameters of an organization object and returns the
8682
* object itself.
87-
*
83+
*
8884
* @return The method is returning an instance of the Organization class.
8985
*/
9086

@@ -96,11 +92,11 @@ protected Organization clearParams() {
9692
/**
9793
* Sets header for the request
9894
*
99-
* @param key
100-
* header key for the request
95+
* @param key header key for the request
10196
*/
102-
public void removeParam(@NotNull String key) {
97+
public Organization removeParam(@NotNull String key) {
10398
this.params.remove(key);
99+
return this;
104100
}
105101

106102
/**
@@ -162,15 +158,10 @@ public Call<ResponseBody> find() {
162158
* @return Call
163159
*/
164160
public Call<ResponseBody> fetch() {
165-
validate();
161+
Objects.requireNonNull(this.organizationUid, ERROR_MSG);
166162
return service.getSingle(this.headers, organizationUid, this.params);
167163
}
168164

169-
void validate() {
170-
if (this.organizationUid == null)
171-
throw new IllegalStateException("organizationUid can not be null or empty");
172-
}
173-
174165
/**
175166
* Gets organization role.
176167
*
@@ -213,7 +204,7 @@ void validate() {
213204
* @return Call
214205
*/
215206
public Call<ResponseBody> roles() {
216-
validate();
207+
Objects.requireNonNull(this.organizationUid, ERROR_MSG);
217208
return service.getRoles(this.headers, this.organizationUid, this.params);
218209
}
219210

@@ -226,12 +217,11 @@ public Call<ResponseBody> roles() {
226217
* <p>
227218
* When executing the API call, provide the Organization UID
228219
*
229-
* @param body
230-
* the request body JSONObject
220+
* @param body the request body JSONObject
231221
* @return Call
232222
*/
233223
public Call<ResponseBody> inviteUser(JSONObject body) {
234-
validate();
224+
Objects.requireNonNull(this.organizationUid, ERROR_MSG);
235225
return service.inviteUser(this.headers, this.organizationUid, body);
236226
}
237227

@@ -244,12 +234,11 @@ public Call<ResponseBody> inviteUser(JSONObject body) {
244234
* users from your organization
245235
* <br>
246236
*
247-
* @param body
248-
* the request body JSONObject
237+
* @param body the request body JSONObject
249238
* @return Call
250239
*/
251240
public Call<ResponseBody> removeUsers(JSONObject body) {
252-
validate();
241+
Objects.requireNonNull(this.organizationUid, ERROR_MSG);
253242
return service.removeUser(this.headers, this.organizationUid, body);
254243
}
255244

@@ -262,12 +251,11 @@ public Call<ResponseBody> removeUsers(JSONObject body) {
262251
* Organization can resend the invitation to
263252
* add users to an Organization
264253
*
265-
* @param shareUid
266-
* the share uid
254+
* @param shareUid the share uid
267255
* @return Call
268256
*/
269257
public Call<ResponseBody> resendInvitation(String shareUid) {
270-
validate();
258+
Objects.requireNonNull(this.organizationUid, ERROR_MSG);
271259
return service.resendInvitation(this.headers, this.organizationUid, shareUid);
272260
}
273261

@@ -338,7 +326,7 @@ public Call<ResponseBody> resendInvitation(String shareUid) {
338326
* @return Call
339327
*/
340328
public Call<ResponseBody> allInvitations() {
341-
validate();
329+
Objects.requireNonNull(this.organizationUid, ERROR_MSG);
342330
return service.getAllInvitations(this.headers, this.organizationUid, this.params);
343331
}
344332

@@ -349,12 +337,11 @@ public Call<ResponseBody> allInvitations() {
349337
* for accepting the ownership of a
350338
* particular Organization is sent to the specified user<br>
351339
*
352-
* @param body
353-
* The request body @codes { "transfer_to": "[email protected]" }
340+
* @param body The request body @codes { "transfer_to": "[email protected]" }
354341
* @return Call
355342
*/
356343
public Call<ResponseBody> transferOwnership(JSONObject body) {
357-
validate();
344+
Objects.requireNonNull(this.organizationUid, ERROR_MSG);
358345
return service.transferOwnership(this.headers, this.organizationUid, body);
359346
}
360347

@@ -402,7 +389,7 @@ public Call<ResponseBody> transferOwnership(JSONObject body) {
402389
* @return Call
403390
*/
404391
public Call<ResponseBody> stacks() {
405-
validate();
392+
Objects.requireNonNull(this.organizationUid, ERROR_MSG);
406393
return service.getStacks(this.headers, this.organizationUid, this.params);
407394
}
408395

@@ -440,12 +427,11 @@ public Call<ResponseBody> logsDetails() {
440427
* </b>
441428
* <br>
442429
*
443-
* @param logUid
444-
* the log uid
430+
* @param logUid the log uid
445431
* @return Call
446432
*/
447433
public Call<ResponseBody> logItem(String logUid) {
448-
validate();
434+
Objects.requireNonNull(this.organizationUid, ERROR_MSG);
449435
return service.getLogItems(this.headers, this.organizationUid, logUid);
450436
}
451437

src/main/java/com/contentstack/cms/organization/OrganizationService.java

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,68 +9,68 @@
99

1010
public interface OrganizationService {
1111

12-
@GET("organizations")
13-
Call<ResponseBody> fetch(
14-
@HeaderMap Map<String, String> headers,
15-
@QueryMap Map<String, Object> query);
12+
@GET("organizations")
13+
Call<ResponseBody> fetch(
14+
@HeaderMap Map<String, String> headers,
15+
@QueryMap Map<String, Object> query);
1616

17-
@GET("organizations/{organization_uid}")
18-
Call<ResponseBody> getSingle(
19-
@HeaderMap Map<String, String> headers,
20-
@Path("organization_uid") String uid,
21-
@QueryMap Map<String, Object> query);
17+
@GET("organizations/{organization_uid}")
18+
Call<ResponseBody> getSingle(
19+
@HeaderMap Map<String, String> headers,
20+
@Path("organization_uid") String uid,
21+
@QueryMap Map<String, Object> query);
2222

23-
@GET("organizations/{organization_uid}/roles")
24-
Call<ResponseBody> getRoles(
25-
@HeaderMap Map<String, String> headers,
26-
@Path("organization_uid") String uid,
27-
@QueryMap Map<String, Object> query);
23+
@GET("organizations/{organization_uid}/roles")
24+
Call<ResponseBody> getRoles(
25+
@HeaderMap Map<String, String> headers,
26+
@Path("organization_uid") String uid,
27+
@QueryMap Map<String, Object> query);
2828

29-
@POST("organizations/{organization_uid}/share")
30-
Call<ResponseBody> inviteUser(
31-
@HeaderMap Map<String, String> headers,
32-
@Path("organization_uid") String uid,
33-
@Body JSONObject body);
29+
@POST("organizations/{organization_uid}/share")
30+
Call<ResponseBody> inviteUser(
31+
@HeaderMap Map<String, String> headers,
32+
@Path("organization_uid") String uid,
33+
@Body JSONObject body);
3434

35-
@HTTP(method = "DELETE", path = "organizations/{organization_uid}/share", hasBody = true)
36-
Call<ResponseBody> removeUser(
37-
@HeaderMap Map<String, String> headers,
38-
@Path("organization_uid") String uid,
39-
@Body JSONObject body);
35+
@HTTP(method = "DELETE", path = "organizations/{organization_uid}/share", hasBody = true)
36+
Call<ResponseBody> removeUser(
37+
@HeaderMap Map<String, String> headers,
38+
@Path("organization_uid") String uid,
39+
@Body JSONObject body);
4040

41-
@GET("organizations/{organization_uid}/share/{share_uid}/resend_invitation")
42-
Call<ResponseBody> resendInvitation(
43-
@HeaderMap Map<String, String> headers,
44-
@Path("organization_uid") String uid,
45-
@Path("share_uid") String shareUid);
41+
@GET("organizations/{organization_uid}/share/{share_uid}/resend_invitation")
42+
Call<ResponseBody> resendInvitation(
43+
@HeaderMap Map<String, String> headers,
44+
@Path("organization_uid") String uid,
45+
@Path("share_uid") String shareUid);
4646

47-
@GET("organizations/{organization_uid}/share")
48-
Call<ResponseBody> getAllInvitations(
49-
@HeaderMap Map<String, String> headers,
50-
@Path("organization_uid") String uid,
51-
@QueryMap Map<String, Object> query);
47+
@GET("organizations/{organization_uid}/share")
48+
Call<ResponseBody> getAllInvitations(
49+
@HeaderMap Map<String, String> headers,
50+
@Path("organization_uid") String uid,
51+
@QueryMap Map<String, Object> query);
5252

53-
@POST("organizations/{organization_uid}/transfer-ownership")
54-
Call<ResponseBody> transferOwnership(
55-
@HeaderMap Map<String, String> headers,
56-
@Path("organization_uid") String uid,
57-
@Body JSONObject body);
53+
@POST("organizations/{organization_uid}/transfer-ownership")
54+
Call<ResponseBody> transferOwnership(
55+
@HeaderMap Map<String, String> headers,
56+
@Path("organization_uid") String uid,
57+
@Body JSONObject body);
5858

59-
@GET("organizations/{organization_uid}/stacks")
60-
Call<ResponseBody> getStacks(
61-
@HeaderMap Map<String, String> headers,
62-
@Path("organization_uid") String uid,
63-
@QueryMap Map<String, Object> query);
59+
@GET("organizations/{organization_uid}/stacks")
60+
Call<ResponseBody> getStacks(
61+
@HeaderMap Map<String, String> headers,
62+
@Path("organization_uid") String uid,
63+
@QueryMap Map<String, Object> query);
6464

65-
@GET("organizations/{organization_uid}/logs")
66-
Call<ResponseBody> getLogDetails(
67-
@HeaderMap Map<String, String> headers,
68-
@Path("organization_uid") String uid);
65+
@GET("organizations/{organization_uid}/logs")
66+
Call<ResponseBody> getLogDetails(
67+
@HeaderMap Map<String, String> headers,
68+
@Path("organization_uid") String uid);
6969

70-
@GET("organizations/{organization_uid}/logs/{log_uid}")
71-
Call<ResponseBody> getLogItems(
72-
@HeaderMap Map<String, String> headers,
73-
@Path("organization_uid") String uid,
74-
@Path("log_uid") String logUid);
70+
@GET("organizations/{organization_uid}/logs/{log_uid}")
71+
Call<ResponseBody> getLogItems(
72+
@HeaderMap Map<String, String> headers,
73+
@Path("organization_uid") String uid,
74+
@Path("log_uid") String logUid);
7575

7676
}

src/main/java/com/contentstack/cms/stack/Alias.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void addParam(@NotNull String key, @NotNull Object value) {
9191
* key of the parameter
9292
* that needs to be removed from the "params" collection.
9393
*/
94-
public void removeParam(@NotNull String key) {
94+
protected void removeParam(@NotNull String key) {
9595
this.params.remove(key);
9696
}
9797

@@ -106,7 +106,6 @@ protected void clearParams() {
106106
*
107107
* @return Call
108108
* @author ***REMOVED***
109-
* @version v0.1.0
110109
* @see <a href=
111110
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-all-aliases">Get
112111
* all
@@ -122,7 +121,6 @@ public Call<ResponseBody> find() {
122121
*
123122
* @return Call
124123
* @author ***REMOVED***
125-
* @version v0.1.0
126124
* @see <a href=
127125
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#get-a-single-branch">
128126
* Get a single branch</a>
@@ -148,7 +146,6 @@ public Call<ResponseBody> fetch() {
148146
* the request body
149147
* @return Call
150148
* @author ***REMOVED***
151-
* @version v0.1.0
152149
* @see <a href=
153150
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#assign-or-update-an-alias">Update
154151
* a
@@ -171,7 +168,6 @@ public Call<ResponseBody> update(@NotNull JSONObject body) {
171168
*
172169
* @return Call
173170
* @author ***REMOVED***
174-
* @version v0.1.0
175171
* @see <a href=
176172
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-an-alias">Delete
177173
* a branch</a>

0 commit comments

Comments
 (0)