PrincipalPolicyImpl extends AbstractAccessControlList implements PrincipalAccessControlList { @Override public void orderBefore(@NotNull AccessControlEntry srcEntry, @Nullable AccessControlEntry destEntry) throws RepositoryException { EntryImpl src = validateEntry(srcEntry); EntryImpl dest = (destEntry == null) ? null : validateEntry(destEntry); if (src.equals(dest)) { log.debug("'srcEntry' equals 'destEntry' -> no reordering."); return; } int index = -1; if (dest != null) { index = entries.indexOf(dest); if (index < 0) { throw new AccessControlException("Destination entry not contained in this AccessControlList."); } } if (entries.remove(src)) { if (index != -1) { entries.add(index, src); } else { entries.add(src); } } else { throw new AccessControlException("Source entry not contained in this AccessControlList"); } } PrincipalPolicyImpl(@NotNull Principal principal, @NotNull String oakPath, @NotNull MgrProvider mgrProvider); @Override @NotNull List<EntryImpl> getEntries(); @Override @NotNull RestrictionProvider getRestrictionProvider(); @Override @NotNull Principal getPrincipal(); @Override boolean addEntry(@Nullable String effectivePath, @NotNull Privilege[] privileges); @Override boolean addEntry(@Nullable String effectivePath, @NotNull Privilege[] privileges, @NotNull Map<String, Value> restrictions, @NotNull Map<String, Value[]> mvRestrictions); @Override boolean addEntry(@NotNull Principal principal, @NotNull Privilege[] privileges, boolean isAllow, @Nullable Map<String, Value> restrictions, @Nullable Map<String, Value[]> mvRestrictions); @Override void orderBefore(@NotNull AccessControlEntry srcEntry, @Nullable AccessControlEntry destEntry); @Override void removeAccessControlEntry(AccessControlEntry ace);  }
@Test public void testOrderBefore() throws Exception { PrincipalPolicyImpl.Entry entryA = policy.getEntries().get(0); PrincipalPolicyImpl.Entry entryB = policy.getEntries().get(1); policy.orderBefore(entryB, entryA); assertArrayEquals(new AccessControlEntry[] {entryB, entryA}, policy.getAccessControlEntries()); }