Permissions { public static long diff(long permissions, long otherPermissions) { return permissions & ~otherPermissions; } private  Permissions(); static Set<String> getNames(long permissions); static String getString(long permissions); static boolean isRepositoryPermission(long permission); static boolean isAggregate(long permission); static Iterable<Long> aggregates(final long permissions); static boolean includes(long permissions, long permissionsToTest); static boolean respectParentPermissions(long permissions); static long diff(long permissions, long otherPermissions); static long getPermissions(@NotNull String jcrActions,
                                      @NotNull TreeLocation location,
                                      boolean isAccessControlContent); static long getPermissions(@Nullable String permissionNames); static long getPermission(@Nullable String path, long defaultPermission); static final long NO_PERMISSION; static final long READ_NODE; static final long READ_PROPERTY; static final long ADD_PROPERTY; static final long MODIFY_PROPERTY; static final long REMOVE_PROPERTY; static final long ADD_NODE; static final long REMOVE_NODE; static final long READ_ACCESS_CONTROL; static final long MODIFY_ACCESS_CONTROL; static final long NODE_TYPE_MANAGEMENT; static final long VERSION_MANAGEMENT; static final long LOCK_MANAGEMENT; static final long LIFECYCLE_MANAGEMENT; static final long RETENTION_MANAGEMENT; static final long MODIFY_CHILD_NODE_COLLECTION; static final long NODE_TYPE_DEFINITION_MANAGEMENT; static final long NAMESPACE_MANAGEMENT; static final long WORKSPACE_MANAGEMENT; static final long PRIVILEGE_MANAGEMENT; static final long USER_MANAGEMENT; static final long INDEX_DEFINITION_MANAGEMENT; static final long READ; static final long REMOVE; static final long SET_PROPERTY; static final long WRITE; static final long ALL; static final Map<Long, String> PERMISSION_NAMES; }
@Test public void testDiff() { assertEquals(Permissions.NO_PERMISSION, Permissions.diff(Permissions.ADD_NODE, Permissions.ADD_NODE)); assertEquals(Permissions.READ_PROPERTY, Permissions.diff(Permissions.READ, Permissions.READ_NODE)); assertEquals(Permissions.WRITE, Permissions.diff(Permissions.WRITE, Permissions.MODIFY_ACCESS_CONTROL)); assertEquals(Permissions.WRITE, Permissions.diff(Permissions.WRITE, Permissions.NO_PERMISSION)); assertEquals(Permissions.NO_PERMISSION, Permissions.diff(Permissions.WRITE, Permissions.WRITE)); assertEquals(Permissions.SET_PROPERTY | Permissions.REMOVE_NODE | Permissions.LOCK_MANAGEMENT, Permissions.diff(Permissions.WRITE | Permissions.LOCK_MANAGEMENT, Permissions.ADD_NODE)); assertEquals(Permissions.LOCK_MANAGEMENT, Permissions.diff(Permissions.LOCK_MANAGEMENT | Permissions.ADD_PROPERTY, Permissions.ADD_PROPERTY)); }
@Test public void testDiffFromAllPermissions() { assertEquals(Permissions.ALL, Permissions.diff(Permissions.ALL, Permissions.NO_PERMISSION)); assertEquals(Permissions.NO_PERMISSION, Permissions.diff(Permissions.ALL, Permissions.ALL)); long expected = (Permissions.READ_ACCESS_CONTROL | Permissions.MODIFY_ACCESS_CONTROL | Permissions.NODE_TYPE_MANAGEMENT | Permissions.VERSION_MANAGEMENT | Permissions.LOCK_MANAGEMENT | Permissions.LIFECYCLE_MANAGEMENT | Permissions.RETENTION_MANAGEMENT | Permissions.MODIFY_CHILD_NODE_COLLECTION | Permissions.NODE_TYPE_DEFINITION_MANAGEMENT | Permissions.NAMESPACE_MANAGEMENT | Permissions.WORKSPACE_MANAGEMENT | Permissions.PRIVILEGE_MANAGEMENT | Permissions.USER_MANAGEMENT | Permissions.INDEX_DEFINITION_MANAGEMENT ); assertEquals(expected, Permissions.diff(Permissions.ALL, Permissions.READ|Permissions.WRITE)); }
@Test public void testDiffFromNoPermissions() { assertEquals(Permissions.NO_PERMISSION, Permissions.diff(Permissions.NO_PERMISSION, Permissions.ADD_NODE)); assertEquals(Permissions.NO_PERMISSION, Permissions.diff(Permissions.NO_PERMISSION, Permissions.ALL)); assertEquals(Permissions.NO_PERMISSION, Permissions.diff(Permissions.NO_PERMISSION, Permissions.NO_PERMISSION)); }