// assumes that the global "session" belongs to an Administrator protected void setPermissionToAnonymous(String perm) { DocumentModel doc = session.getRootDocument(); ACP acp = doc.getACP(); if (acp == null) { acp = new ACPImpl(); } UserEntryImpl userEntry = new UserEntryImpl("anonymous"); userEntry.addPrivilege(perm); acp.setRules("test", new UserEntry[] {userEntry}); doc.setACP(acp, true); session.save(); }
protected void setPermissionToEveryone(String... perms) { DocumentModel doc = session.getRootDocument(); ACP acp = doc.getACP(); if (acp == null) { acp = new ACPImpl(); } UserEntryImpl userEntry = new UserEntryImpl(EVERYONE); for (String perm : perms) { userEntry.addPrivilege(perm); } acp.setRules("test", new UserEntry[] {userEntry}); doc.setACP(acp, true); session.save(); }