Utils implements Constants { public static Privilege[] privilegesFromOakNames(@NotNull Set<String> privilegeNames, @NotNull PrivilegeManager privilegeManager, @NotNull NamePathMapper namePathMapper) { return Collections2.filter(Collections2.transform(privilegeNames, privilegeName -> { try { return privilegeManager.getPrivilege(namePathMapper.getJcrName(privilegeName)); } catch (RepositoryException e) { log.error("Unknown privilege in access control entry : {}", privilegeName); return null; } }), Predicates.notNull()).toArray(new Privilege[0]); } private  Utils(); static boolean isPrincipalPolicyTree(@NotNull Tree tree); static boolean isPrincipalEntry(@NotNull Tree tree); static boolean canHandle(@NotNull Principal principal, @NotNull Filter filter, int importBehavior); static Privilege[] privilegesFromOakNames(@NotNull Set<String> privilegeNames, @NotNull PrivilegeManager privilegeManager, @NotNull NamePathMapper namePathMapper); static boolean hasModAcPermission(@NotNull PermissionProvider permissionProvider, @NotNull String effectivePath);  }
@Test public void testPrivilegesFromNamesEmptyNames() { assertArrayEquals(new Privilege[0], Utils.privilegesFromOakNames(Collections.emptySet(), Mockito.mock(PrivilegeManager.class), NamePathMapper.DEFAULT)); }
@Test public void testPrivilegesFromNamesInvalidName() throws Exception { assertArrayEquals(new Privilege[0], Utils.privilegesFromOakNames(Collections.singleton(INVALID_PRIVILEGE_NAME), mockPrivilegeManager(), NamePathMapper.DEFAULT)); }
@Test public void testPrivilegesFromNamesRemapped() throws Exception { NamePathMapper mapper = Mockito.mock(NamePathMapper.class); when(mapper.getJcrName(any())).thenReturn("c"); Privilege[] privs = Utils.privilegesFromOakNames(Sets.newHashSet("a", "b"), mockPrivilegeManager(), mapper); assertEquals(2, privs.length); for (Privilege p : privs) { assertEquals("c", p.getName()); } }