Skip to content

Commit 506f059

Browse files
Add bulk release item management methods and update API documentation
- Implement methods for adding, updating, and deleting release items in BulkOperation and ReleaseItem classes. - Enhance BulkOperationService with new API endpoints for bulk operations. - Update ReleaseService to include methods for moving and deleting items in a release. - Improve Javadoc comments for clarity and consistency.
1 parent da77857 commit 506f059

File tree

4 files changed

+140
-16
lines changed

4 files changed

+140
-16
lines changed

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

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
* @author ***REMOVED***
2525
* @version v1.0.0
2626
* @see <a href=
27-
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#bulk-publish-operation">
28-
* Bulk Operations Queue </a>
27+
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#bulk-publish-operation">
28+
* Bulk Operations Queue </a>
2929
* @since 2023 -08-23
3030
*/
3131
public class BulkOperation implements BaseImplementation<BulkOperation> {
@@ -49,7 +49,7 @@ public class BulkOperation implements BaseImplementation<BulkOperation> {
4949
*
5050
* @param retrofit the retrofit
5151
*/
52-
protected BulkOperation(Retrofit retrofit,Map<String, Object> headers) {
52+
protected BulkOperation(Retrofit retrofit, Map<String, Object> headers) {
5353
this.headers = new HashMap<>();
5454
this.headers.putAll(headers);
5555
this.params = new HashMap<>();
@@ -88,9 +88,9 @@ protected BulkOperation(Retrofit retrofit,Map<String, Object> headers) {
8888
* @param body The JSON object containing the data to be published.
8989
* @return Call object for the API request.
9090
* @see <a
91-
* href=
92-
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#publish-entries-and-assets-in-bulk">
93-
* Publish entries and assets in bulk </a>
91+
* href=
92+
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#publish-entries-and-assets-in-bulk">
93+
* Publish entries and assets in bulk </a>
9494
* @see #addHeader(String, String) #addHeader(String, String)to add headers in
9595
* @see #addParam(String, Object) #addParam(String, Object)to add query
9696
* @since 1.0.0
@@ -130,11 +130,11 @@ public Call<ResponseBody> publish(@NotNull JSONObject body) {
130130
* @param body the body
131131
* @return Call call
132132
* @see <a href=
133-
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#bulk-unpublish-operation">Bulk
134-
* Unpublish Operation </a>
133+
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#bulk-unpublish-operation">Bulk
134+
* Unpublish Operation </a>
135135
* @see #addHeader(String, String) #addHeader(String, String)to add headers
136136
* @see #addParam(String, Object) #addParam(String, Object)to add query
137-
* parameters
137+
* parameters
138138
* @since 0.1.0
139139
*/
140140
public Call<ResponseBody> unpublish(@NotNull JSONObject body) {
@@ -159,11 +159,11 @@ public Call<ResponseBody> unpublish(@NotNull JSONObject body) {
159159
* @param body the body
160160
* @return Call call
161161
* @see <a href=
162-
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-entries-and-assets-in-bulk">Bulk
163-
* Delete Operation </a>
162+
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-entries-and-assets-in-bulk">Bulk
163+
* Delete Operation </a>
164164
* @see #addHeader(String, String) #addHeader(String, String)to add headers
165165
* @see #addParam(String, Object) #addParam(String, Object)to add query
166-
* parameters
166+
* parameters
167167
* @since 0.1.0
168168
*/
169169
public Call<ResponseBody> delete(JSONObject body) {
@@ -190,16 +190,61 @@ public Call<ResponseBody> delete(JSONObject body) {
190190
* @param body the body
191191
* @return Call
192192
* @see <a href=
193-
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-entries-and-assets-in-bulk">Bulk
194-
* Delete Operation </a>
193+
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-entries-and-assets-in-bulk">Bulk
194+
* Delete Operation </a>
195195
* @see #addHeader(String, String) #addHeader(String, String)to add headers
196196
* @see #addParam(String, Object) #addParam(String, Object)to add query
197-
* parameters
197+
* parameters
198198
* @since 0.1.0
199199
*/
200200
public Call<ResponseBody> updateWorkflow(@NotNull JSONObject body) {
201201
return this.service.updateWorkflowDetails(this.headers, this.params, body);
202202
}
203+
/**
204+
* The Add Release items request allows you to add multiple items (entries and
205+
* assets) to a Release.
206+
* <p>
207+
* When executing the API request, you need to provide the Release UID. In the
208+
* 'Body' section, you need to provide
209+
* the details of the items
210+
*
211+
* @param jsonBody requestBody for create/add single Item
212+
* @return Call
213+
*/
214+
public Call<ResponseBody> addReleaseItems(@NotNull JSONObject jsonBody) {
215+
Call<ResponseBody> addItemsCall;
216+
this.headers.put("bulk_version", "2.0");
217+
addItemsCall = this.service.addBulkItems(this.headers, this.params, jsonBody);
218+
this.headers.remove("bulk_version");
219+
return addItemsCall;
220+
}
221+
222+
/**
223+
* The Update Release items request to Update release items to latest version
224+
*/
225+
public Call<ResponseBody> updateReleaseItems(@NotNull JSONObject jsonBody) {
226+
Call<ResponseBody> updateItemsCall;
227+
this.headers.put("bulk_version", "2.0");
228+
updateItemsCall = this.service.updateBulkItems(this.headers, this.params, jsonBody);
229+
this.headers.remove("bulk_version");
230+
return updateItemsCall;
231+
}
232+
233+
/**
234+
* The Get Job Status request allows you to get the status of a job.
235+
* <p>
236+
* When executing the API request, you need to provide the job UID.
237+
*
238+
* @param jobUid the job UID
239+
* @return Call
240+
*/
241+
public Call<ResponseBody> jobStatus(@NotNull String jobUid) {
242+
Call<ResponseBody> jobStatusCall;
243+
this.headers.put("bulk_version", "2.0");
244+
jobStatusCall = this.service.getJobStatus(this.headers, this.params, jobUid);
245+
this.headers.remove("bulk_version");
246+
return jobStatusCall;
247+
}
203248

204249
/**
205250
* Adds a header with the specified key and value to this location and returns
@@ -236,7 +281,8 @@ public BulkOperation addHeader(@NotNull String key, @NotNull String value) {
236281
* location.
237282
*
238283
* @param params a {@link HashMap} containing the parameters to be added
239-
* @return a new {@link BulkOperation} object with the specified parameters added
284+
* @return a new {@link BulkOperation} object with the specified parameters
285+
* added
240286
* @throws NullPointerException if the params argument is null
241287
*/
242288
@Override

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
import org.json.simple.JSONObject;
55
import retrofit2.Call;
66
import retrofit2.http.Body;
7+
import retrofit2.http.GET;
78
import retrofit2.http.HeaderMap;
89
import retrofit2.http.POST;
10+
import retrofit2.http.PUT;
11+
import retrofit2.http.Path;
912
import retrofit2.http.QueryMap;
1013

1114
import java.util.HashMap;
@@ -37,4 +40,22 @@ Call<ResponseBody> updateWorkflowDetails(
3740
@QueryMap HashMap<String, Object> params,
3841
@Body JSONObject body);
3942

43+
@POST("bulk/release/items")
44+
Call<ResponseBody> addBulkItems(
45+
@HeaderMap Map<String, Object> headers,
46+
@QueryMap Map<String, Object> params,
47+
@Body JSONObject body); //required
48+
49+
@PUT("bulk/release/update_items")
50+
Call<ResponseBody> updateBulkItems(
51+
@HeaderMap Map<String, Object> headers,
52+
@QueryMap Map<String, Object> params,
53+
@Body JSONObject body); //required
54+
55+
@GET("bulk/jobs/{job_id}")
56+
Call<ResponseBody> getJobStatus(
57+
@HeaderMap Map<String, Object> headers,
58+
@QueryMap Map<String, Object> params,
59+
@Path("job_id") String jobUid); //required
60+
4061
}

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,41 @@ public Call<ResponseBody> delete() {
244244
return this.service.removeItem(this.headers, this.releaseUid);
245245
}
246246

247+
/**
248+
* The Deletes a multiple items request deteles multiple items from a Release
249+
*
250+
* @param jsonBody requestBody for delete Items
251+
* @return Call
252+
*/
253+
public Call<ResponseBody> deleteReleaseItems(@NotNull JSONObject jsonBody) {
254+
validate();
255+
return this.service.deleteItems(this.headers, this.releaseUid, this.params, jsonBody);
256+
}
257+
258+
/**
259+
* The Delete a single item request delete single item from a Release
260+
*
261+
* @param jsonBody requestBody for delete single Item
262+
* @return Call
263+
*/
264+
public Call<ResponseBody> deleteReleaseItem(@NotNull JSONObject jsonBody) {
265+
validate();
266+
return this.service.deleteItem(this.headers, this.releaseUid, this.params, jsonBody);
267+
}
268+
269+
/**
270+
* The Move items in a Release request allows you to move one or more items
271+
* (entries and/or assets) from one
272+
* Release to another.
273+
*
274+
* @param jsonBody requestBody for move items
275+
* @return Call
276+
*/
277+
public Call<ResponseBody> move(@NotNull JSONObject jsonBody) {
278+
validate();
279+
this.headers.put("release_version", "2.0");
280+
Call<ResponseBody> moveCall = this.service.moveItems(this.headers, this.releaseUid, this.params, jsonBody);
281+
this.headers.remove("release_version", "2.0");
282+
return moveCall;
283+
}
247284
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,24 @@ Call<ResponseBody> clone(
7979
@QueryMap Map<String, Object> params,
8080
@Body JSONObject body);
8181

82+
@POST("/releases/{source_releaseUid}/items/move")
83+
Call<ResponseBody> moveItems(
84+
@HeaderMap Map<String, Object> headers,
85+
@Path("source_releaseUid") String releaseUid,
86+
@QueryMap Map<String, Object> params,
87+
@Body JSONObject body); //required
88+
89+
@DELETE("/releases/{release_uid}/items")
90+
Call<ResponseBody> deleteItems(
91+
@HeaderMap Map<String, Object> headers,
92+
@Path("release_uid") String releaseUid,
93+
@QueryMap Map<String, Object> params,
94+
@Body JSONObject body); //required
95+
96+
@DELETE("/releases/{release_uid}/items")
97+
Call<ResponseBody> deleteItem(
98+
@HeaderMap Map<String, Object> headers,
99+
@Path("release_uid") String releaseUid,
100+
@QueryMap Map<String, Object> params,
101+
@Body JSONObject body); //required
82102
}

0 commit comments

Comments
 (0)