cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to delete Content Rules using Javascript API ?

msevestre
Champ in-the-making
Champ in-the-making
Hello

I will migrate my data to the latest version of Alfresco and at the same time, I want to delete all the Content Rules that exists in my current data tree as they will become useless.

I am able to change rights using javascripts without problems (via calls to SetPermission(), etc..), but I have not found any solution to delete a content rule. Could you please help me ?

Thank you for your help
Matthew
11 REPLIES 11

mitpatoliya
Star Collaborator
Star Collaborator
AFAIK there is not such direct API available which will help you in this case.
If you want you can create your custom javascript API's to achieve this.

msevestre
Champ in-the-making
Champ in-the-making
Hi

I don't think I have the capabilities to build such an API… so I'll keep my useless rules contents or take time to delete them one by one. Smiley Happy

Thanks

Matt

mitpatoliya
Star Collaborator
Star Collaborator
I think this is what you can check once. Each rule alfresco store under one space which has type rule on which it is created. you will not able able to see it on UI but internally from node-browser you will be able to see it.
So, what I think is that if you some how manage to delete them though script rule should also be deleted. Just give it a try and let us know if it works.

msevestre
Champ in-the-making
Champ in-the-making
I don't see how to do this unfortunately. If anyone whish to help, it would be a pleasure to try !

kaynezhang
World-Class Innovator
World-Class Innovator
why don't you consider to use   webscript as instead.
webscript api

DELETE /alfresco/service/api/node/{store_type}/{store_id}/{id}/ruleset/rules/{rule_id}

msevestre
Champ in-the-making
Champ in-the-making
Hi

that's not a problem using webscript… but as I'm not very "fluent" in Alfresco background, I don't know how to define the values between the "{..}"

Matt

kaynezhang
World-Class Innovator
World-Class Innovator

{store_type} - that is, the type of store
{store_id} - the id of the store
{id} - the id of the node whose rules you want to delete
{rule_id} - the id of the rule you want to delete



alfreco default  store is  workspace://SpacesStore ,so your url may be like this

/alfresco/service/api/node/workspace/SpacesStore/3446584b-6605-4871-8fbc-0131c6f44584/ruleset/rules/b680b35f-303b-4189-822e-4fb99b4024cc

msevestre
Champ in-the-making
Champ in-the-making
Hi

OK thanks. I was successfull to list the rules first… unfortunately, this API is aimed to work on a specific node.

What I want to do is to act, starting for a node, recursively in all children nodes (deleting by hand through the web interface will not be longer than using the API)

Maybe there's a trick to display recursively all the rules ? If yes, then you mya have find the full solution Smiley Happy

Matt

kaynezhang
World-Class Innovator
World-Class Innovator
workspace://SpacesStore/e7d585dd-16f1-4b31-9cd5-a9f8e2869a17

You can use search
GET /alfresco/service/slingshot/search
to search all node you want to delete
then iterate each node and get all rules applied to it by
 /api/node/{store_type}/{store_id}/{id}/ruleset/rules?ruleType={rule_type?}

then delete each rule by

/alfresco/service/api/node/{store_type}/{store_id}/{id}/ruleset/rules/{rule_id}