@Override public String getPath() { return pathMapper.getJcrPath(path); } }
@Nonnull @Override public String getJcrName(@Nonnull String oakName) { return namePathMapper.getJcrName(oakName); }
@Override @Nullable public String getOakPath(String jcrPath) { return namePathMapper.getOakPath(jcrPath); }
@Override public String getPath() { return PathUtils.concat( mapper.getJcrPath(parent), mapper.getJcrName(name)); }
@Override @SuppressWarnings("deprecation") public Value getValue(int type) throws RepositoryException { if (type == PropertyType.BINARY) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { Base64.decode(value, baos); return valueFactory.createValue( new ByteArrayInputStream(baos.toByteArray())); } catch (IOException e) { throw new RepositoryException( "Failed to decode binary value: " + value, e); } } // The ValueFactory instance takes care of name and path mapping // from JCR to Oak values, but here we need an additional level of // mapping for XML to JCR values. String jcrValue; if (type == PropertyType.NAME) { jcrValue = namePathMapper.getOakName(value); } else if (type == PropertyType.PATH) { jcrValue = namePathMapper.getOakPath(value); } else { jcrValue = value; } return valueFactory.createValue(jcrValue, type); }
String oakName = namePathMapper.getOakNameOrNull(name); if (oakName == null) { LOG.warn("Ignoring invalid property name: {}", name); new NodeEventHandler("/", info, namePathMapper, oakPropertyNames)); String oakPath = namePathMapper.getOakPath(path); if (oakPath == null) { LOG.warn("Cannot listen for changes on invalid path: {}", path);
@Test public void testEmptyName() throws RepositoryException { assertEquals("", npMapper.getJcrName("")); assertEquals("", npMapper.getOakNameOrNull("")); assertEquals("", npMapper.getOakName("")); }
private static NamePathMapper mockNamePathMapper(String testPath) { NamePathMapper npMapper = Mockito.mock(NamePathMapper.class); when(npMapper.getOakPath("/")).thenReturn("/"); when(npMapper.getOakPath(null)).thenReturn(null); when(npMapper.getOakPath(testPath)).thenReturn(testPath); when(npMapper.getOakPath("/jr:testPath")).thenReturn("/oak:testPath"); when(npMapper.getOakPath("/{http://jackrabbit.apache.org}testPath")).thenReturn("/oak:testPath"); when(npMapper.getJcrPath("/")).thenReturn("/"); when(npMapper.getJcrPath(null)).thenReturn(null); when(npMapper.getJcrPath(testPath)).thenReturn(testPath); when(npMapper.getJcrPath("/oak:testPath")).thenReturn("/jr:testPath"); when(npMapper.getJcrPath("/{http://jackrabbit.apache.org}testPath")).thenReturn("/jr:testPath"); return npMapper; }
@Override @Nonnull public String getOakName(@Nonnull String jcrName) throws RepositoryException { return namePathMapper.getOakName(jcrName); }
private boolean matches(String childNodeName, String name) { String oakChildName = mapper.getOakNameOrNull(childNodeName); String oakName = mapper.getOakNameOrNull(name); // TODO need a better way to handle SNS return oakChildName != null && oakChildName.startsWith(oakName); }
@NotNull private Iterator<Authorizable> findAuthorizables(@NotNull String statement, long limit, long offset, @Nullable AuthorizableType type) throws RepositoryException { try { Result query = root.getQueryEngine().executeQuery( statement, javax.jcr.query.Query.XPATH, limit, offset, NO_BINDINGS, namePathMapper.getSessionLocalMappings()); Iterable<? extends ResultRow> resultRows = query.getRows(); Iterator<Authorizable> authorizables = Iterators.transform(resultRows.iterator(), new ResultRowToAuthorizable(userManager, root, type)); return Iterators.filter(authorizables, new UniqueResultPredicate()); } catch (ParseException e) { log.warn("Invalid user query: " + statement, e); throw new RepositoryException(e); } }
@Override @SuppressWarnings("deprecation") public Value getValue(int type) throws RepositoryException { if (type == PropertyType.BINARY) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { Base64.decode(value, baos); return valueFactory.createValue( new ByteArrayInputStream(baos.toByteArray())); } catch (IOException e) { throw new RepositoryException( "Failed to decode binary value: " + value, e); } } // The ValueFactory instance takes care of name and path mapping // from JCR to Oak values, but here we need an additional level of // mapping for XML to JCR values. String jcrValue; if (type == PropertyType.NAME) { jcrValue = namePathMapper.getOakName(value); } else if (type == PropertyType.PATH) { jcrValue = namePathMapper.getOakPath(value); } else { jcrValue = value; } return valueFactory.createValue(jcrValue, type); }
String oakName = namePathMapper.getOakNameOrNull(name); if (oakName == null) { LOG.warn("Ignoring invalid property name: {}", name); new NodeEventHandler("/", info, namePathMapper, oakPropertyNames)); String oakPath = namePathMapper.getOakPath(path); if (oakPath == null) { LOG.warn("Cannot listen for changes on invalid path: {}", path);
@Override public String getPath() { return PathUtils.concat( mapper.getJcrPath(parent), mapper.getJcrName(name)); }
@Override @NotNull public String getOakName(@NotNull String jcrName) throws RepositoryException { return namePathMapper.getOakName(jcrName); }
private boolean matches(String childNodeName, String name) { String oakChildName = mapper.getOakNameOrNull(childNodeName); String oakName = mapper.getOakNameOrNull(name); // TODO need a better way to handle SNS return oakChildName != null && oakChildName.startsWith(oakName); }
@NotNull private Iterator<Authorizable> findAuthorizables(@NotNull String statement, long limit, long offset, @Nullable AuthorizableType type) throws RepositoryException { try { Result query = root.getQueryEngine().executeQuery( statement, javax.jcr.query.Query.XPATH, limit, offset, NO_BINDINGS, namePathMapper.getSessionLocalMappings()); Iterable<? extends ResultRow> resultRows = query.getRows(); Iterator<Authorizable> authorizables = Iterators.transform(resultRows.iterator(), new ResultRowToAuthorizable(userManager, root, type)); return Iterators.filter(authorizables, new UniqueResultPredicate()); } catch (ParseException e) { log.warn("Invalid user query: " + statement, e); throw new RepositoryException(e); } }
@Override public String getPath() { return pathMapper.getJcrPath(path); } }
@Override @CheckForNull public String getOakPath(String jcrPath) { return namePathMapper.getOakPath(jcrPath); }
@Override public String apply(RestrictionDefinition definition) { return namePathMapper.getJcrName(definition.getName()); } }).toArray(new String[supported.size()]);