Block permissions inheritance with automation Chain
hello, In Nuxe 6, i want to block permissions inheritance in an automation Chain
- Context.FetchDocument
- Document.Create: type: P019_020_DOC_formulaireNomination properties: “dc:title”: “Formulaire de nomination : @{nomUser["nom"]}” “dc:description”: “@{cxt_critereNomination} @{nomUser["directiveSpecifique"]}”
- Document.AddPermission: permission: ReadWrite user: “@{nomUser["nom"]}” acl: local blockInheritance: “false”
- Context.RunScript: script: “org.nuxeo.ecm.core.api.DocumentModel docModel = org.nuxeo.ecm.automation.jsf.OperationHelper.getNavigationContext().getCurrentDocument(); org.nuxeo.ecm.core.api.DocumentRef docRef = docModel.getRef(); org.nuxeo.ecm.core.api.security.ACP acp =@{This.session}.getACP(docRef); acp.getOrCreateACL().add(new ACE(SecurityConstants.EVERYONE, SecurityConstants.EVERYTHING, false));”
- Document.Save
I use “Context.RunScript” to block then inheritance but i ahve an error :
“Error: could not access: session; in class: org.nuxeo.ecm.automation.core.collectors.DocumentModelCollector] [Near : {… security.ACP acp =@{This.session}.getACP(docRef); ….}]”
I can not find the correct syntax to replace @{This.session} ?
Thank
answer :
- Context.SetVar:
name: cxt_currentDocument
value: “@{Document}“ - Context.RunScript:
script: " org.nuxeo.ecm.automation.core.scripting.DocumentWrapper docModelWraper = Context["cxt_currentDocument"]; org.nuxeo.ecm.core.api.DocumentModel docModel = docModelWraper.getDoc(); org.nuxeo.ecm.core.api.DocumentRef docRef = docModel.getRef(); org.nuxeo.ecm.core.api.security.ACP acp =docModel.getCoreSession().getACP(docRef);
//block inheritance
org.nuxeo.ecm.core.api.security.ACE myAce = new org.nuxeo.ecm.core.api.security.ACE(org.nuxeo.ecm.core.api.security.SecurityConstants.EVERYONE, org.nuxeo.ecm.core.api.security.SecurityConstants.EVERYTHING, false);
acp.getOrCreateACL().add(myAce);
docModel.getCoreSession().setACP(docRef, acp, true);
“
- Document.Save