- CPS-314Getting issue details... STATUS
Currently, in CPS, it is only possible to create a dataspace that will hold YANG modules and allow the service to create instances of the models via anchors.
It will be advantageous to provide a function that allows the deletion of the created dataspace provided that all anchors in that dataspace have also been deleted.
To realise 'Delete dataspace' functionality, the following must be implemented:
REST Endpoint in CPS-Core
Java API method in CPS-Service
Data Persistence Service
Issues
# | Issue | Notes | Decision |
---|---|---|---|
1 | Abandoned SchemaSets | Question: Will the SchemaSets be automatically deleted once all anchors using them have been deleted? SchemaSets are not automatically deleted once the anchors using them have been deleted SchemaSets are deleted once dataspace holding it is deleted | Agreed with Toine Siebelink that a dataspace can only be deleted if there are no anchors and no schemasets associated with it. The existence of either of these will lead to an exception. see issue #2 below |
2 | Dataspace not empty exception | If dataspace is not empty, throw exception 'DataspaceNotEmptyException' (?) | We decided to use the CPS Exception |
Implementation Proposal
REST layers
cpsAdmin.yml
- Create delete function to endpoint
AdminRestController.java
- Implement a method to delete a dataspace with a dataspace name of type String as a parameter
- Invokes cpsAdminService
- Returns code 404 if the dataspace given does not exist
Service layers
cpsAdminService.java
- Create abstract method
void deleteDataspace {String dataspaceName)
cpsAdminServiceImpl.java
- Invokes cpsAdminPersistenceService for method deleteDataspace
Persistence layers
cpsAdminPersistenceService.java
- Create abstract method
void deleteDataspace {String dataspaceName)
cpsAdminPersistenceServiceImpl.java
- Invoke method dataspaceRepository.getByName(String dataspaceName) to get dataspace entity
- Throws 'DataspaceNotFoundException' if dataspace does not exist
- Invoke method 'getAnchors()' to confirm that dataspace has no anchors
- If dataspace is not empty, throw exception 'DataspaceNotEmptyException' (?)
- Using JPA, delete dataspace
- Invoke method dataspaceRepository.getByName(String dataspaceName) to get dataspace entity