@Override public boolean replace(ACE oldACE, ACE newACE) { boolean aclChanged = false; int index = indexOf(oldACE); if (index != -1) { remove(oldACE); add(index, newACE); aclChanged = true; } return aclChanged; }
protected void setACE(final DocumentRef ref) throws NuxeoException { final List<ACE>[] aceList = slurpACEs(entries); final ACP acp = session.getACP(ref); ACLImpl acl = (ACLImpl) acp.getACL(aclName); if ((acl == null) || doOverwrite) { acl = new ACLImpl(aclName); acl.addAll(aceList[0]); } else { for (final ACE ace : aceList[0]) { if (!acl.contains(ace)) { acl.add(0, ace); } } } acl.removeAll(aceList[1]); acp.addACL(acl); session.setACP(ref, acp, doOverwrite); }
/** * ajout une ace sur un document * * @param session * @param ref * @param ace * @throws NuxeoException */ public static void setACE(CoreSession session, DocumentRef ref, ACE ace) throws NuxeoException { ACPImpl acp = new ACPImpl(); ACLImpl acl = new ACLImpl(ACL.LOCAL_ACL); acp.addACL(acl); acl.add(ace); session.setACP(ref, acp, false); }
/** * ajout une ace sur un document * @param session * @param ref * @param ace * @throws ClientException */ public static void setACE(CoreSession session, DocumentRef ref,ACE ace) throws ClientException { ACPImpl acp = new ACPImpl(); ACLImpl acl = new ACLImpl(ACL.LOCAL_ACL); acp.addACL(acl); acl.add(ace); session.setACP(ref, acp, false); }
protected void setACE(DocumentRef ref) { ACPImpl acp = new ACPImpl(); ACLImpl acl = new ACLImpl(aclName); acp.addACL(acl); ACE ace = new ACE(user, permission, grant); acl.add(ace); session.setACP(ref, acp, overwrite); }
@POST @Path("add") public Response postPermission() { HttpServletRequest req = ctx.getRequest(); String action = req.getParameter("action"); String permission = req.getParameter("permission"); String username = req.getParameter("user"); UserManager userManager = Framework.getService(UserManager.class); NuxeoPrincipal user = userManager.getPrincipal(username); if (user == null) { NuxeoGroup group = userManager.getGroup(username); if (group == null) { return Response.status(500).build(); } } ACPImpl acp = new ACPImpl(); ACLImpl acl = new ACLImpl(ACL.LOCAL_ACL); acp.addACL(acl); boolean granted = "grant".equals(action); ACE ace = new ACE(username, permission, granted); acl.add(ace); CoreSession session = ctx.getCoreSession(); Resource target = getTarget(); session.setACP(target.getAdapter(DocumentModel.class).getRef(), acp, false); session.save(); return redirect(target.getPath()); }
protected static void setLocalAcl(CoreSession session, DocumentModel doc, String value) { ACPImpl acp = new ACPImpl(); ACLImpl acl = new ACLImpl(ACL.LOCAL_ACL); acp.addACL(acl); String[] entries = StringUtils.split(value, ',', true); if (entries.length == 0) { return; } for (String entry : entries) { String[] ace = StringUtils.split(entry, ':', true); acl.add(new ACE(ace[0], ace[1], Boolean.parseBoolean(ace[2]))); } session.setACP(doc.getRef(), acp, false); }