-
Story
-
Resolution: Done
-
Medium
-
None
-
None
-
None
An endpoint already exists in ServicesServlet
- method: deleteService()
- url: /sdc2/rest/v1/catalog/services/{resourceId})
However the implementation of this endpoint only marks the service as deleted rather than actually deleting anything from the DB.
Option 1
Add a parameter to the existing endpoint to indicate if delete should 'mark for deletion' or actually delete, e.g. could be enum with values MARK_AS_DELETE, DELETE. For backwards compatibility the new param would need to be optional with default to keep the existing behaviour of mark for delete
Option 2 - Chosen
Create a new endpoint
Option 2 is probably cleaner but leaving the existing endpoint already uses the logical name/path for the delete method and is a source of confusion
The implementation should:
- check if the service is archived. The request should be rejected if the service is not archived
- check if the service is used in any service. If it is used in any service (regardless of the state of that service), the delete request should fail with an appropriate error message returned indicating the services in which there are instances of the VF
- if the above 2 checks pass, proceed to delete all versions of the service from janusgraph.
- See ArchiveOperation::doAction( ) which has similarities to what we want to do here
- Get all versions of the service. Versions of the service are connected by edges of type VERSION.
- Traverse the edges of the service versions to also delete the other vertices that have been created for the resource (e.g. edges of type ARTIFACTS, TOSCA_ARTIFACTS, DEPLOYMENT_ARTIFACTS, INPUTS, INST_PROPERTIES, CALCULATED_REQUIREMENTS, FULLFILLED_REQUIREMENTS, CALCULATED_CAPABILITIES, FULLFILLED_CAPABILITIES, CALCULATED_CAP_PROPERTIES, INST_ATTRIBUTES, POLICIES)
- Make sure not to delete vertices connected to the service that are more general and not specific to the service (e.g. edges of type CATEGORY, INSTANCE_OF, MODEL) but make sure the edges are deleted (probably happens when service vertex is deleted?)
- Delete all versions of the service
- If a package specific model was created for the service then this model should be deleted as well.
- Publish a message on SDC-FACADE-NOTIF topic to inform consumers of the delete (see ComponentBusinessLogic::markComponentToDelete() -> updateCatalog()
The existing endpoint /sdc2/rest/v1/inactiveComponents/{componentType} (ElementServlet::deleteMarkedResources()) which can be used to delete services which have been marked for deletion contains most of the logic we need so a lot of that code can be re-used
Note on verification: ensure verification that service is not deleted when used in another service for both SDC model and ETSI model as the method of nesting the services is handled differently on both (service proxy for SDC service substitution for ETSI)