Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
harshithad0703 committed May 27, 2025
commit 506f0599105d0a09ca68ee93b2350e7478d3e935
78 changes: 62 additions & 16 deletions src/main/java/com/contentstack/cms/stack/BulkOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* @author ***REMOVED***
* @version v1.0.0
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#bulk-publish-operation">
* Bulk Operations Queue </a>
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#bulk-publish-operation">
* Bulk Operations Queue </a>
* @since 2023 -08-23
*/
public class BulkOperation implements BaseImplementation<BulkOperation> {
Expand All @@ -49,7 +49,7 @@ public class BulkOperation implements BaseImplementation<BulkOperation> {
*
* @param retrofit the retrofit
*/
protected BulkOperation(Retrofit retrofit,Map<String, Object> headers) {
protected BulkOperation(Retrofit retrofit, Map<String, Object> headers) {
this.headers = new HashMap<>();
this.headers.putAll(headers);
this.params = new HashMap<>();
Expand Down Expand Up @@ -88,9 +88,9 @@ protected BulkOperation(Retrofit retrofit,Map<String, Object> headers) {
* @param body The JSON object containing the data to be published.
* @return Call object for the API request.
* @see <a
* href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#publish-entries-and-assets-in-bulk">
* Publish entries and assets in bulk </a>
* href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#publish-entries-and-assets-in-bulk">
* Publish entries and assets in bulk </a>
* @see #addHeader(String, String) #addHeader(String, String)to add headers in
* @see #addParam(String, Object) #addParam(String, Object)to add query
* @since 1.0.0
Expand Down Expand Up @@ -130,11 +130,11 @@ public Call<ResponseBody> publish(@NotNull JSONObject body) {
* @param body the body
* @return Call call
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#bulk-unpublish-operation">Bulk
* Unpublish Operation </a>
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#bulk-unpublish-operation">Bulk
* Unpublish Operation </a>
* @see #addHeader(String, String) #addHeader(String, String)to add headers
* @see #addParam(String, Object) #addParam(String, Object)to add query
* parameters
* parameters
* @since 0.1.0
*/
public Call<ResponseBody> unpublish(@NotNull JSONObject body) {
Expand All @@ -159,11 +159,11 @@ public Call<ResponseBody> unpublish(@NotNull JSONObject body) {
* @param body the body
* @return Call call
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-entries-and-assets-in-bulk">Bulk
* Delete Operation </a>
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-entries-and-assets-in-bulk">Bulk
* Delete Operation </a>
* @see #addHeader(String, String) #addHeader(String, String)to add headers
* @see #addParam(String, Object) #addParam(String, Object)to add query
* parameters
* parameters
* @since 0.1.0
*/
public Call<ResponseBody> delete(JSONObject body) {
Expand All @@ -190,16 +190,61 @@ public Call<ResponseBody> delete(JSONObject body) {
* @param body the body
* @return Call
* @see <a href=
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-entries-and-assets-in-bulk">Bulk
* Delete Operation </a>
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#delete-entries-and-assets-in-bulk">Bulk
* Delete Operation </a>
* @see #addHeader(String, String) #addHeader(String, String)to add headers
* @see #addParam(String, Object) #addParam(String, Object)to add query
* parameters
* parameters
* @since 0.1.0
*/
public Call<ResponseBody> updateWorkflow(@NotNull JSONObject body) {
return this.service.updateWorkflowDetails(this.headers, this.params, body);
}
/**
* The Add Release items request allows you to add multiple items (entries and
* assets) to a Release.
* <p>
* When executing the API request, you need to provide the Release UID. In the
* 'Body' section, you need to provide
* the details of the items
*
* @param jsonBody requestBody for create/add single Item
* @return Call
*/
public Call<ResponseBody> addReleaseItems(@NotNull JSONObject jsonBody) {
Call<ResponseBody> addItemsCall;
this.headers.put("bulk_version", "2.0");
addItemsCall = this.service.addBulkItems(this.headers, this.params, jsonBody);
this.headers.remove("bulk_version");
return addItemsCall;
}

/**
* The Update Release items request to Update release items to latest version
*/
public Call<ResponseBody> updateReleaseItems(@NotNull JSONObject jsonBody) {
Call<ResponseBody> updateItemsCall;
this.headers.put("bulk_version", "2.0");
updateItemsCall = this.service.updateBulkItems(this.headers, this.params, jsonBody);
this.headers.remove("bulk_version");
return updateItemsCall;
}

/**
* The Get Job Status request allows you to get the status of a job.
* <p>
* When executing the API request, you need to provide the job UID.
*
* @param jobUid the job UID
* @return Call
*/
public Call<ResponseBody> jobStatus(@NotNull String jobUid) {
Call<ResponseBody> jobStatusCall;
this.headers.put("bulk_version", "2.0");
jobStatusCall = this.service.getJobStatus(this.headers, this.params, jobUid);
this.headers.remove("bulk_version");
return jobStatusCall;
}

/**
* Adds a header with the specified key and value to this location and returns
Expand Down Expand Up @@ -236,7 +281,8 @@ public BulkOperation addHeader(@NotNull String key, @NotNull String value) {
* location.
*
* @param params a {@link HashMap} containing the parameters to be added
* @return a new {@link BulkOperation} object with the specified parameters added
* @return a new {@link BulkOperation} object with the specified parameters
* added
* @throws NullPointerException if the params argument is null
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import org.json.simple.JSONObject;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.HeaderMap;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.QueryMap;

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

@POST("bulk/release/items")
Call<ResponseBody> addBulkItems(
@HeaderMap Map<String, Object> headers,
@QueryMap Map<String, Object> params,
@Body JSONObject body); //required

@PUT("bulk/release/update_items")
Call<ResponseBody> updateBulkItems(
@HeaderMap Map<String, Object> headers,
@QueryMap Map<String, Object> params,
@Body JSONObject body); //required

@GET("bulk/jobs/{job_id}")
Call<ResponseBody> getJobStatus(
@HeaderMap Map<String, Object> headers,
@QueryMap Map<String, Object> params,
@Path("job_id") String jobUid); //required

}
37 changes: 37 additions & 0 deletions src/main/java/com/contentstack/cms/stack/ReleaseItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,41 @@ public Call<ResponseBody> delete() {
return this.service.removeItem(this.headers, this.releaseUid);
}

/**
* The Deletes a multiple items request deteles multiple items from a Release
*
* @param jsonBody requestBody for delete Items
* @return Call
*/
public Call<ResponseBody> deleteReleaseItems(@NotNull JSONObject jsonBody) {
validate();
return this.service.deleteItems(this.headers, this.releaseUid, this.params, jsonBody);
}

/**
* The Delete a single item request delete single item from a Release
*
* @param jsonBody requestBody for delete single Item
* @return Call
*/
public Call<ResponseBody> deleteReleaseItem(@NotNull JSONObject jsonBody) {
validate();
return this.service.deleteItem(this.headers, this.releaseUid, this.params, jsonBody);
}

/**
* The Move items in a Release request allows you to move one or more items
* (entries and/or assets) from one
* Release to another.
*
* @param jsonBody requestBody for move items
* @return Call
*/
public Call<ResponseBody> move(@NotNull JSONObject jsonBody) {
validate();
this.headers.put("release_version", "2.0");
Call<ResponseBody> moveCall = this.service.moveItems(this.headers, this.releaseUid, this.params, jsonBody);
this.headers.remove("release_version", "2.0");
return moveCall;
}
}
20 changes: 20 additions & 0 deletions src/main/java/com/contentstack/cms/stack/ReleaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,24 @@ Call<ResponseBody> clone(
@QueryMap Map<String, Object> params,
@Body JSONObject body);

@POST("/releases/{source_releaseUid}/items/move")
Call<ResponseBody> moveItems(
@HeaderMap Map<String, Object> headers,
@Path("source_releaseUid") String releaseUid,
@QueryMap Map<String, Object> params,
@Body JSONObject body); //required

@DELETE("/releases/{release_uid}/items")
Call<ResponseBody> deleteItems(
@HeaderMap Map<String, Object> headers,
@Path("release_uid") String releaseUid,
@QueryMap Map<String, Object> params,
@Body JSONObject body); //required

@DELETE("/releases/{release_uid}/items")
Call<ResponseBody> deleteItem(
@HeaderMap Map<String, Object> headers,
@Path("release_uid") String releaseUid,
@QueryMap Map<String, Object> params,
@Body JSONObject body); //required
}