feat(rest): create new endpoint for bulk delete function #2416
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: #2415, #1649
Create new endpoint for bulk delete function (#1468).
How To Test?
Preparations
Exclusion Behavior Confirmation
After starting the system, sign in as an Admin user and register a Release with the following structure.
Open the detail screen of each Release in a web browser and confirm the ID of the Release.
Use any RestAPI client tool to execute the RestAPI.
HTTP Method: DELETE
URL:http://{your-host}/resource/api/releases/{release-id}/bulkDelete
Response Confirmation
Confirm that the following records have not been deleted.
[Release]
DeleteLibrary001 1.00
DeleteLibrary002 1.00
DeleteLibrary003 1.00
[Component]
DeleteLibrary001
DeleteLibrary002
DeleteLibrary003
Confirmation of Preview Mode Operation
After starting the system, sign in as an Admin user and register a Release with the following structure.
Open the detail screen of each Release in a web browser and confirm the ID of the Release.
Use any RestAPI client tool to execute the RestAPI.
HTTP Method: DELETE
URL: http://{your-host}/resource/api/releases/{release-id}/bulkDelete?isPreview=true
Response Confirmation
Confirm that the following records have not been deleted.
[Release]
ExcludeLibrary001 1.00
RemainLibrary001 1.00
DeleteLibrary004 1.00
DeleteLibrary005 1.00
DeleteLibrary006 1.00
[Component]
ExcludeLibrary001
RemainLibrary001
DeleteLibrary004
DeleteLibrary005
DeleteLibrary006
Bulk Deletion Confirmation
After starting the system, sign in as an Admin user and register a Release with the following structure.
Open the detail screen of each Release in a web browser and confirm the ID of the Release.
Use any RestAPI client tool to execute the RestAPI.
HTTP Method: DELETE
URL: http://{your-host}/resource/api/releases/{release-id}/bulkDelete
Response Confirmation
Replace the ID of the release according to the test data.
Confirm that the following records have not been deleted.
[Release]
ExcludeLibrary001 1.00
RemainLibrary001 1.00
[Component]
ExcludeLibrary001
RemainLibrary001
Confirm that the following records have been deleted.
[Release]
DeleteLibrary004 1.00
DeleteLibrary005 1.00
DeleteLibrary006 1.00
[Component]
DeleteLibrary004
DeleteLibrary005
DeleteLibrary006
Operation by a User without Admin Privileges
Open the detail screen of any Release in a web browser and confirm the ID of the Release.
Use any RestAPI client tool to execute the RestAPI.
HTTP method: DELETE
URL: http://{your-host}/resource/api/releases/{release-id}/bulkDelete
Response Confirmation
Checklist
Must:
Overview of improvements
Purpose
The bulk delete function is a feature that allows for the deletion of a group of Releases and unused Components that are linked together, starting from a specified Release.
The purpose of this change is to enable the execution of the bulk delete function from the RestAPI, in anticipation of transitioning the frontend to Next.js.
The operating conditions and limitations are the same as the UI version of the bulk delete function.
To enable the bulk delete function, it is necessary to enable the Admin’s Private access function.
Add the following entries to sw360.properties:
Summary of Function Changes
Addition of Endpoint
The following endpoint has been added to the SW360 RestAPI.
true: Only perform operation check without deleting data on the DB. (For preview screen)
false: Delete data on the DB.
Sample URL:
Key Points of Code Changes
Addition of endpoint for bulk delete function
ReleaseController
rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/release/ReleaseController.java
bulkDeleteReleases method
Added a Java method corresponding to the endpoint “/{id}/bulkDelete” for the bulk delete function.
Sw360ReleaseService
rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/release/Sw360ReleaseService.java
deleteBulkRelease method
Added common RestAPI processing to call the backend processing of the bulk delete function.
JacksonCustomizations
rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/core/JacksonCustomizations.java
BulkOperationNodeMixin class
Added a Mixin class containing instructions to the serializer during response JSON generation.
Bug fixes
Modified backend logic to fix bugs discovered in testing.
BulkDeleteUtil
backend/src-common/src/main/java/org/eclipse/sw360/datahandler/db/BulkDeleteUtil.java
deleteBulkRelease method
Fixed a bug where the links of subordinate Releases were deleted when a Release referenced from an external project was bulk deleted.
BulkDeleteUtilTest
backend/src/src-components/src/test/java/org/eclipse/sw360/components/db/BulkDeleteUtilTest.java
Added Maven tests to address the aforementioned bug.
Data Structure
DB Records
The bulk delete function analyzes the dependency tree of existing data each time and deletes the data. Therefore, the bulk delete function does not hold any tree information in the database.
Response JSON
The API of the bulk delete function returns JSON data in the following format after execution. The structure of the JSON data is based on the assumption that it will be displayed on the bulk delete screen of the UI, and the format is such that Components and Releases appear alternately.
Data class corresponding to the response data:
org.eclipse.sw360.datahandler.thrift.components.BulkOperationNode
DB Migration
There are no changes to the DB structure due to this modification.
Limitations