@Override @CheckForNull public String getOakPath(String jcrPath) { return namePathMapper.getOakPath(jcrPath); }
@Override @Nullable public String getOakPath(String jcrPath) { return namePathMapper.getOakPath(jcrPath); }
private static Set<String> getOakPaths(NamePathMapper mapper, String[] paths) { Set<String> oakPaths = newHashSet(); for (String path : paths) { oakPaths.add(mapper.getOakPath(path)); } return oakPaths; }
private static Set<String> getOakPaths(NamePathMapper mapper, String[] paths) { Set<String> oakPaths = newHashSet(); for (String path : paths) { oakPaths.add(mapper.getOakPath(path)); } return oakPaths; }
@CheckForNull protected String getOakPath(@Nullable String jcrPath) throws RepositoryException { if (jcrPath == null) { return null; } else { String oakPath = namePathMapper.getOakPath(jcrPath); if (oakPath == null || !PathUtils.isAbsolute(oakPath)) { throw new RepositoryException("Failed to resolve JCR path " + jcrPath); } return oakPath; } }
@Nullable protected String getOakPath(@Nullable String jcrPath) throws RepositoryException { if (jcrPath == null) { return null; } else { String oakPath = namePathMapper.getOakPath(jcrPath); if (oakPath == null || !PathUtils.isAbsolute(oakPath)) { throw new RepositoryException("Failed to resolve JCR path " + jcrPath); } return oakPath; } }
@NotNull private String getOakPath(@Nullable String relPath) throws RepositoryException { if (relPath == null || relPath.isEmpty() || relPath.charAt(0) == '/') { throw new RepositoryException("Relative path expected. Found " + relPath); } String oakPath = valueFactory.getNamePathMapper().getOakPath(relPath); if (oakPath == null) { throw new RepositoryException("Failed to resolve relative path: " + relPath); } return oakPath; }
@NotNull private String getOakPath(@Nullable String relPath) throws RepositoryException { if (relPath == null || relPath.isEmpty() || relPath.charAt(0) == '/') { throw new RepositoryException("Relative path expected. Found " + relPath); } String oakPath = valueFactory.getNamePathMapper().getOakPath(relPath); if (oakPath == null) { throw new RepositoryException("Failed to resolve relative path: " + relPath); } return oakPath; }
@Override public Authorizable getAuthorizableByPath(String path) throws RepositoryException { String oakPath = namePathMapper.getOakPath(path); if (oakPath == null) { throw new RepositoryException("Invalid path " + path); } return getAuthorizableByOakPath(oakPath); }
@Override String getOakPath() { String groupPath = getPath(); return (groupPath == null) ? null : namePathMapper.getOakPath(getPath()); }
@Override public Authorizable getAuthorizableByPath(String path) throws RepositoryException { String oakPath = namePathMapper.getOakPath(path); if (oakPath == null) { throw new RepositoryException("Invalid path " + path); } return getAuthorizableByOakPath(oakPath); }
public TestACL(@Nullable String jcrPath, @NotNull RestrictionProvider restrictionProvider, @NotNull NamePathMapper namePathMapper, @NotNull List<JackrabbitAccessControlEntry> entries) { super((jcrPath == null) ? null : namePathMapper.getOakPath(jcrPath), namePathMapper); this.entries.addAll(entries); this.restrictionProvider = restrictionProvider; }
@Override String getOakPath() { String groupPath = getPath(); return (groupPath == null) ? null : getNamePathMapper().getOakPath(getPath()); }
@Override String getOakPath() { String groupPath = getPath(); return (groupPath == null) ? null : getNamePathMapper().getOakPath(getPath()); }
protected ImmutableACL createACL(@Nullable String jcrPath, @NotNull List<JackrabbitAccessControlEntry> entries, @NotNull NamePathMapper namePathMapper, @NotNull RestrictionProvider restrictionProvider) { String oakPath = (jcrPath == null) ? null : namePathMapper.getOakPath(jcrPath); return new ImmutableACL(oakPath, entries, restrictionProvider, namePathMapper); }
@Test public void testTrailingSlash() { assertEquals("/oak-foo:bar/oak-quu:qux",npMapper.getOakPath("/foo:bar/quu:qux/")); assertEquals("/a/b/c",npMapper.getOakPath("/a/b/c/")); }
@Test public void testJcrToOakKeepIndexNoRemap() { NameMapper mapper = new GlobalNameMapper(GLOBAL); NamePathMapper npMapper = new NamePathMapperImpl(mapper); assertEquals("/", npMapper.getOakPath("/")); assertEquals("/foo:bar", npMapper.getOakPath("/foo:bar")); assertEquals("/foo:bar/quu:qux", npMapper.getOakPath("/foo:bar/quu:qux")); assertEquals("foo:bar", npMapper.getOakPath("foo:bar")); }
@Test public void testInvalidIdentifierPath() { String uuid = UUIDUtils.generateUUID(); List<String> invalid = new ArrayList<String>(); invalid.add('[' + uuid + "]abc"); invalid.add('[' + uuid + "]/a/b/c"); for (String jcrPath : invalid) { assertNull(npMapper.getOakPath(jcrPath)); } }
@Test public void testIllegalBracketsInPaths() throws Exception { String[] paths = { "/parent/sub/{childB7", "/parent/sub/{childB7", "/parent/{", "/parent/{childA1", "/parent/{{childA2" }; for (String path : paths) { assertNull(npMapper.getOakPath(path)); } }
@Test public void testWhitespace() { String[] paths = new String[] { " leading", "trailing\n", " ", "\t", "oak: leading", "oak:trailing\n", "oak: ", "oak:\t" }; NamePathMapper noLocal = new NamePathMapperImpl(new LocalNameMapper( GLOBAL, Collections.<String, String>emptyMap())); for (String path : paths) { assertEquals("without local mappings", path, noLocal.getOakPath(path)); assertEquals("with local mappings", path, npMapper.getOakPath(path)); } }