private void replaceInherited(Long id, Acl acl, List<Ace> inherited, List<Integer> positions, int depth) { truncateInherited(id, depth); addInherited(acl, inherited, positions, depth); }
/** * {@inheritDoc} */ @Override public Long createAccessControlList() { return createAccessControlList(getDefaultProperties()).getId(); }
/** * {@inheritDoc} */ @Override public Acl getAclCopy(Long toCopy, Long toInheritFrom, ACLCopyMode mode) { return getAclEntityCopy(toCopy, toInheritFrom, mode); }
/** * {@inheritDoc} */ @Override public Acl createLayeredAcl(Long indirectedAcl) { SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties(); properties.setAclType(ACLType.LAYERED); Acl acl = createAccessControlList(properties); long id = acl.getId(); if (indirectedAcl != null) { mergeInheritedAccessControlList(indirectedAcl, id); } return acl; }
removeAcesFromAcl(id, exclude, depth); aclCrudDAO.addAclMembersToAcl(acl.getId(), toAdd, depth); break; case CHANGE_INHERITED: replaceInherited(id, acl, inherited, positions, depth); break; case ADD_INHERITED: addInherited(acl, inherited, positions, depth); break; case TRUNCATE_INHERITED: truncateInherited(id, depth); break; case INSERT_INHERITED: insertInherited(id, acl, inherited, positions, depth); break; case REMOVE_INHERITED: removeInherited(id, depth); break; case CREATE_AND_INHERIT: aclCrudDAO.addAclMembersToAcl(acl.getId(), toAdd, depth); addInherited(acl, inherited, positions, depth); case COPY_ONLY: default: acl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(acl); return new AclChangeImpl(id, id, acl.getAclType(), acl.getAclType()); else if ((acl.getAclChangeSetId() == getCurrentChangeSetId()) && (!requiresVersion) && (!acl.getRequiresVersion()))
return getInheritedAccessControlList(toCopy); aclToCopy = aclCrudDAO.getAclForUpdate(toCopy); aclToCopy.setRequiresVersion(true); aclToCopy.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(aclToCopy); inheritedId = getInheritedAccessControlList(toCopy); if ((inheritedId != null) && (!inheritedId.equals(toCopy))) inheritedAcl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(inheritedAcl); return getInheritedAccessControlList(toInheritFrom); List<AclChange> changes = mergeInheritedAccessControlList(toInheritFrom, toCopy); for (AclChange change : changes) return getInheritedAccessControlList(toInheritFrom); Long id = createAccessControlList(properties).getId(); AccessControlList indirectAcl = getAccessControlList(toCopy); for (AccessControlEntry entry : indirectAcl.getEntries()) setAccessControlEntry(id, entry); mergeInheritedAccessControlList(toInheritFrom, id); return getInheritedAccessControlList(toInheritFrom);
acl.setAclChangeSetId(getCurrentChangeSetId()); acl.setRequiresVersion(false); if (inherited != null) toInherit = getInheritedAccessControlList(inherited); getWritable(created, toInherit, excluded, toAdd, toInherit, false, changes, WriteMode.CREATE_AND_INHERIT); return getAcl(created);
properties.setInherits(Boolean.TRUE); properties.setVersioned(acl.isVersioned()); Long sharedId = createAccessControlList(properties, null, null).getId(); getWritable(sharedId, id, null, null, id, true, changes, WriteMode.ADD_INHERITED); acl.setInheritedAcl(sharedId); inheritedAclId = sharedId; acl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(acl); return inheritedAclId;
case OLD: acl.setInherits(Boolean.TRUE); acl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(acl); changes.add(new AclChangeImpl(id, id, acl.getAclType(), acl.getAclType())); getWritable(id, null, null, null, null, false, changes, WriteMode.COPY_ONLY); acl = aclCrudDAO.getAclForUpdate(changes.get(0).getAfter()); acl.setInherits(Boolean.TRUE); acl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(acl); getWritable(id, null, null, null, null, false, changes, WriteMode.COPY_ONLY); List<AclChange> merged = mergeInheritedAccessControlList(parent, changes.get(0).getAfter()); changes.addAll(merged); return changes;
getWritable(id, null, null, null, null, false, changes, WriteMode.COPY_ONLY); AclUpdateEntity acl = aclCrudDAO.getAclForUpdate(changes.get(0).getAfter()); final Long inheritsFrom = acl.getInheritsFrom(); acl.setInherits(Boolean.FALSE); acl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(acl); getWritable(acl.getId(), null, null, null, null, true, changes, WriteMode.TRUNCATE_INHERITED); entry.setPosition(Integer.valueOf(0)); setAccessControlEntry(id, entry);
List<Long> nodeIds = getADMNodesByAcl(id, maxForDebug); getWritable(inherited.getId(), acl.getInheritsFrom(), null, null, null, true, acls, WriteMode.REMOVE_INHERITED); Acl unusedInherited = null; for (AclChange change : acls) getWritable(nextId, acl.getInheritsFrom(), null, null, acl.getInheritsFrom(), true, acls, WriteMode.REMOVE_INHERITED); getWritable(nextId, acl.getInheritsFrom(), null, null, null, true, acls, WriteMode.REMOVE_INHERITED); acl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(acl);
/** * {@inheritDoc} */ @Override public List<AclChange> disableInheritance(Long id, boolean setInheritedOnAcl) { AclUpdateEntity acl = aclCrudDAO.getAclForUpdate(id); List<AclChange> changes = new ArrayList<AclChange>(1); switch (acl.getAclType()) { case FIXED: case GLOBAL: return Collections.<AclChange> singletonList(new AclChangeImpl(id, id, acl.getAclType(), acl.getAclType())); case OLD: acl.setInherits(Boolean.FALSE); acl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(acl); changes.add(new AclChangeImpl(id, id, acl.getAclType(), acl.getAclType())); return changes; case SHARED: // TODO support a list of children and casacade if given throw new IllegalArgumentException("Shared ACL must inherit"); case DEFINING: case LAYERED: default: return disableInheritanceImpl(id, setInheritedOnAcl, acl); } }
/** * {@inheritDoc} */ @Override public void deleteAclForNode(long aclId) { Acl dbAcl = getAcl(aclId); if (dbAcl.getAclType() == ACLType.DEFINING) { // delete acl members & acl aclCrudDAO.deleteAclMembersByAcl(aclId); aclCrudDAO.deleteAcl(aclId); } if (dbAcl.getAclType() == ACLType.SHARED) { // check unused Long defining = dbAcl.getInheritsFrom(); if (aclCrudDAO.getAcl(defining) == null) { // ADM if (getADMNodesByAcl(aclId, 1).size() == 0) { // delete acl members & acl aclCrudDAO.deleteAclMembersByAcl(aclId); aclCrudDAO.deleteAcl(aclId); } } } }
private Acl getAclEntityCopy(Long toCopy, Long toInheritFrom, ACLCopyMode mode) { Long id = getCopy(toCopy, toInheritFrom, mode); if (id == null) { return null; } return aclCrudDAO.getAcl(id); }
private void insertInherited(final Long id, AclEntity acl, List<Ace> inherited, List<Integer> positions, int depth) { // get aces for acl (via acl member) List<AclMemberEntity> members = aclCrudDAO.getAclMembersByAclForUpdate(id); for (AclMemberEntity member : members) { if (member.getPos() > depth) { member.setPos(member.getPos() + 1); aclCrudDAO.updateAclMember(member); } } addInherited(acl, inherited, positions, depth); }
break; return createAccessControlList(properties, null, null);
AccessControlListProperties properties = getAccessControlListProperties(id); if (properties == null)
acl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(acl);
removeAcesFromAcl(id, exclude, depth); aclCrudDAO.addAclMembersToAcl(acl.getId(), toAdd, depth); break; case CHANGE_INHERITED: replaceInherited(id, acl, inherited, positions, depth); break; case ADD_INHERITED: addInherited(acl, inherited, positions, depth); break; case TRUNCATE_INHERITED: truncateInherited(id, depth); break; case INSERT_INHERITED: insertInherited(id, acl, inherited, positions, depth); break; case REMOVE_INHERITED: removeInherited(id, depth); break; case CREATE_AND_INHERIT: aclCrudDAO.addAclMembersToAcl(acl.getId(), toAdd, depth); addInherited(acl, inherited, positions, depth); case COPY_ONLY: default: acl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(acl); return new AclChangeImpl(id, id, acl.getAclType(), acl.getAclType()); else if ((acl.getAclChangeSetId() == getCurrentChangeSetId()) && (!requiresVersion) && (!acl.getRequiresVersion()))
return getInheritedAccessControlList(toCopy); aclToCopy = aclCrudDAO.getAclForUpdate(toCopy); aclToCopy.setRequiresVersion(true); aclToCopy.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(aclToCopy); inheritedId = getInheritedAccessControlList(toCopy); if ((inheritedId != null) && (!inheritedId.equals(toCopy))) inheritedAcl.setAclChangeSetId(getCurrentChangeSetId()); aclCrudDAO.updateAcl(inheritedAcl); return getInheritedAccessControlList(toInheritFrom); List<AclChange> changes = mergeInheritedAccessControlList(toInheritFrom, toCopy); for (AclChange change : changes) return getInheritedAccessControlList(toInheritFrom); Long id = createAccessControlList(properties).getId(); AccessControlList indirectAcl = getAccessControlList(toCopy); for (AccessControlEntry entry : indirectAcl.getEntries()) setAccessControlEntry(id, entry); mergeInheritedAccessControlList(toInheritFrom, id); return getInheritedAccessControlList(toInheritFrom);