cancel
Showing results for 
Search instead for 
Did you mean: 

Block permissions inheritance with automation Chain

oguevel_guevel
Confirmed Champ
Confirmed Champ

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

2 REPLIES 2

Greg_Drayon
Star Contributor
Star Contributor

Try docModel.getCoreSession(), without @{}.

oguevel_guevel
Confirmed Champ
Confirmed Champ

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
Getting started

Attention: Blogs & Forums are in READ-ONLY mode from Oct 9-19 as we transition to our new platform. Learn more.

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.