JcrAllUtil { public static PropertyState asPropertyState(@NotNull String name, @NotNull PrivilegeBits bits, @NotNull PrivilegeBitsProvider provider) { if (!bits.isBuiltin() && bits.includes(getAllBits(provider))) { return PropertyStates.createProperty(name, Collections.singletonList(DYNAMIC_JCR_ALL_VALUE), Type.LONGS); } else { return bits.asPropertyState(name); } } private  JcrAllUtil(); static PrivilegeBits getPrivilegeBits(@Nullable PropertyState propertyState, @NotNull PrivilegeBitsProvider provider); static PropertyState asPropertyState(@NotNull String name, @NotNull PrivilegeBits bits, @NotNull PrivilegeBitsProvider provider); static boolean denotesDynamicJcrAll(@Nullable PropertyState property); static final long DYNAMIC_JCR_ALL_VALUE; }
@Test public void testAsPropertyStateBuiltin() { PrivilegeBits readBits = PrivilegeBits.BUILT_IN.get(REP_READ_NODES); PropertyState propertyState = JcrAllUtil.asPropertyState("anyName", readBits, bitsProvider); assertEquals(readBits.asPropertyState("anyName"), propertyState); }
@Test public void testAsPropertyStateCombined() { PrivilegeBits bits = PrivilegeBits.getInstance(); bits.add(PrivilegeBits.BUILT_IN.get(REP_READ_NODES)); bits.add(PrivilegeBits.BUILT_IN.get(REP_WRITE)); PropertyState expected = bits.asPropertyState("anyName"); assertEquals(expected, JcrAllUtil.asPropertyState("anyName", bits, bitsProvider)); }
@Test public void testAsPropertyStateDynamicAll() { assertEquals(DYNAMIC_ALL_PROPERTY, JcrAllUtil.asPropertyState("anyName", ALL_BITS, bitsProvider)); }