It's all about the answers!

Ask a question

How to delete DNG modules via OSLC


Juan Arturo Cruz Cardona (132) | asked Feb 02 '23, 10:27 p.m.

Hi,


I'm trying to delete base artifacts from DNG, using a changeset as the context for the operation. Just to clarify, I'm executing the request from 2 different external services, one is from Postman (testing) and the second one is a web app (used by final users).

My goal is to first delete the instances of the artifact used in the module before removing the base artifact. Otherwise, I get the Error 403: forbidden, because the artifact is being used by a module. 

My DELETE requests look like this:
I discovered that for each instance of the base artifact used in DNG modules, a new ID is generated. So, as I said before, to be able to delete the base artifact we must delete all of the instances of it that are being used. So basically, the algorithm/logic we're using is like this:
  1. Search if there are base artifact instances.
  2. If instances > 0:
    1. For each instance in base artifact instances.
      1.  Execute delete request using artifact instance id.
  3. Fetch base artifact object.
  4. Execute delete request using base artifact id.
The issue is that basically for all instance's deletion request I got 200 responses (valid), but somehow the instances still exist (I can verify this by opening the DNG module through a web browser and seeing the artifact is included), so when I try to delete the base artifact, my delete request response is a 403.

I want to know what's wrong with my current approach. Or if there is a different way to do this operation.

One answer



permanent link
Ian Barnard (1.9k613) | answered Feb 03 '23, 12:26 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Feb 03 '23, 12:40 p.m.
Yes trying to delete a core artifact which has bindings gets a 403 result.

Using the sequence you describe does work, at least for me using 7.0.2 iFix014.:

* Use OSLC Query to find all instances with a specific ID/ name etc., with oslc.select=rm_nav:parent so the parent folder URI is returned for core artifacts (but not for bindings because they don't have a parent folder)
* Search through the results for all the bindings (these don't have an rm_nav:parent property)
*  For each binding URI, DELETE with headers as you describe (But my code doesn't use auth, it authenticates using form POST - that gives the session an authentication cookie that gets sent with all GET/POST/PUT/DELETE) - result is 200
* Then delete the core artifact - result is 200

If the artifact is a module then it itself can't have bindings, and deleting it works fine with no action needed - this deletes all the bindings in the module

I'd check that:
1. Be certain your authentication works - e.g. can you delete a core artifact which doesn't have any module bindings?
2. Are you absolutely definitely providing the correct configuration. My code uses a url query parameter &oslc_config.context= and not a header. I think the correct header would be Configuration.Context have you tried that? A symptom that you aren't using the same config as where you're looking at the module would be that it works once, i.e. when you first delete a binding it's successful, but can't be found if you try to do the same again.
3. Does the REST client method work - I'd focus on getting a rest client to work then get your code to do the same. My experience has been that not all rest clients are equal - I've successfully used RESTClient in Firefox, and YARC in Chrome.
4. I'm hoping that;s a tpyo in your CS url :changesetId - there shouldn't be a : there
6. Ensure you're URL-encoding all query parameter values in your URL. For example:
which is the URL encoded version of:
7. There are occasionally defects fixed in the APIs - update to the most recent iFix and try again.
8. Confirm that your user has permission to delete artifacts - although i'd expect a 403 if you didn't have permission it's still worth checking


Comments
Ian Barnard commented Feb 06 '23, 4:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I added an example of deleting an artifact, removing any bindings first, to my OSS  ELM-Python-Client - refer to examples/dn_simple_deleteartifact.py


NOTE in this example the project/component/configuration are hardcoded and you provide the id on the commandline.

When you run it it will create a logs folder and save a log of the interaction with the server. If you then in the same folder run log2seq it will produce a HTML sequence diagram that can make it a lot easier to see the communication with your server.


Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.